我已经成功实现了与Branck iOS SDK的深度链接。
但是重新打开应用程序时在控制台中显示以下警告:
试图加载视图控制器的视图不允许取消分配,并且可能导致未定义的行为(UIAlertController: 0 x16b00800)
我的AppDelegate
与基本代码实现是:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
// Branch initialization
let branch: Branch = Branch.getInstance()
branch.initSessionWithLaunchOptions(launchOptions, andRegisterDeepLinkHandler:
{ optParams, error in
if error == nil, let params = optParams
{
print("Branch params: ", params.description)
}
})
return true
}
// Respond to URI scheme links
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
{
print("Branch url URI: ", url)
// pass the url to the handle deep link call
Branch.getInstance().handleDeepLink(url)
return true
}
// Respond to Universal Links
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool
{
print("Branch universal link ")
Branch.getInstance().continueUserActivity(userActivity)
return true
}
}
如何删除上述警告?
要消除警告AppDelegate
必须另外实现application:willContinueUserActivityWithType
函数,该函数将返回true
func application(application: UIApplication, willContinueUserActivityWithType userActivityType: String) -> Bool
{
return true
}