Failed to open URL weixin://app/xxxxx/jumpWxa/?xxxxxxx: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.tencent.xin" failed." UserInfo={BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x283d64990 {Error Domain=FBSOpenApplicationErrorDomain Code=3 "Application xxx is neither visible nor entitled, so may not perform un-trusted user actions." UserInfo={BSErrorCodeDescription=Security, NSLocalizedFailureReason=Application com.xxx.xxx is neither visible nor entitled, so may not perform un-trusted user actions.}}, NSLocalizedDescription=The request to open "com.tencent.xin" failed., FBSOpenApplicationRequestID=0x7374, NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace) for reason: Security ("Application com.xxx.xxx is neither visible nor entitled, so may not perform un-trusted user actions").}
手机型号:iPhone 11 Pro max
版本:16.6
现象:
每次跳转 都是正在连接后 回到App。
1. 微信唤起App,App一定会收到系统回调。请确认系统回调是Scheme回调还是Universal Links回调。
2. 如果是Scheme回调,请检查是否走了UISceneDelegate(XCode11构建的项目),或是UIApplicationDelegate。它们的回调方法分别是:
- (void)scene:(UIScene *)scene openURLContexts:(NSSetUIOpenURLContext *> *)URLContexts;
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionaryUIApplicationOpenURLOptionsKey, id> *)options;
3. 如果是Universal Links回调,同样也检查是否走了UISceneDelegate(XCode11构建的项目),或是UIApplicationDelegate。它们的回调方法分别是
- (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArrayidUIUserActivityRest oring>> * __nullable restorableObjects))restorationHandler
4.因为考虑兼容旧版本微信,因此无论Scheme或Universal Links回调都必须处理。 在重写回调方法后,需要分别调用WXApi的handleOpenUrl和handleOpenUniversalLink方法
// AppDelegate.swift
// QuickMiNI
//
//
import Foundation
import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
print("WX Api init")
WXApi.registerApp("111", universalLink: "/")
return true
}
func application(_application:UIApplication, handleOpen url:URL) ->Bool{
return WXApi.handleOpen(url, delegate:self)
}
func application(_ _app:UIApplication, open url:URL, options: [UIApplication.OpenURLOptionsKey:Any] = [:]) ->Bool{
let urlKey: String = options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String
if urlKey == "com.tencent.xin" {
// 微信 的回调
return WXApi.handleOpen(url, delegate: self)
}
return true
}
func application(_application:UIApplication, continue userActivity:NSUserActivity, restorationHandler:@escaping([UIUserActivityRestoring]?) ->Void) ->Bool{
return WXApi.handleOpenUniversalLink(userActivity, delegate:self)
}
}
我已经这样实现了,为什么还是有问题呢
//
// AppDelegate.swift
// QuickMiNI
//
// Created by 胡川港 on 2023/8/15.
//
import Foundation
import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
print("WX Api init")
WXApi.registerApp("", universalLink: "")
return true
}
func application(_application:UIApplication, handleOpen url:URL) ->Bool{
return WXApi.handleOpen(url, delegate:self)
}
func application(_ _app:UIApplication, open url:URL, options: [UIApplication.OpenURLOptionsKey:Any] = [:]) ->Bool{
let urlKey: String = options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String
if urlKey == "com.tencent.xin" {
// 微信 的回调
return WXApi.handleOpen(url, delegate: self)
}
return true
}
func application(_application:UIApplication, continue userActivity:NSUserActivity, restorationHandler:@escaping([UIUserActivityRestoring]?) ->Void) ->Bool{
return WXApi.handleOpenUniversalLink(userActivity, delegate:self)
}
}
2个代理方法都实现了 ,还是有这个问题,打开微信后,显示正在连接,然后就又回到APP了
蹲一下,我也有这个问题
}
func application(_ _app:UIApplication, open url:URL, options: [UIApplication.OpenURLOptionsKey:Any] = [:]) ->Bool{
let urlKey: String = options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String
if urlKey == "com.tencent.xin" {
// 微信 的回调
return WXApi.handleOpen(url, delegate: self)
}
return true
}
func application(_application:UIApplication, continue userActivity:NSUserActivity, restorationHandler:@escaping([UIUserActivityRestoring]?) ->Void) ->Bool{
return WXApi.handleOpenUniversalLink(userActivity, delegate:self)
}
}
是这样吗