iOS9 application:application openURL: sourceApplication: annotation: 方法不执行
Posted Rinpe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS9 application:application openURL: sourceApplication: annotation: 方法不执行相关的知识,希望对你有一定的参考价值。
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url NS_DEPRECATED_ios(2_0, 9_0, "Please use application:openURL:options:") __TVOS_PROHIBITED; - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation NS_DEPRECATED_IOS(4_2, 9_0, "Please use application:openURL:options:") __TVOS_PROHIBITED; - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options NS_AVAILABLE_IOS(9_0); // no equiv. notification. return NO if the application can‘t open for some reason
从上面的API能看出, iOS9之后从其他app回到自己app的时候回调的方法已经变成最后一个了..
所以需要在AppDelegate中重写该方法, 例如:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { // 监听linePay付款完后wap界面跳转 [self handleOpenFromLinePayWithUrl:url]; return YES; } - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options { // 监听linePay付款完后wap界面跳转 [self handleOpenFromLinePayWithUrl:url]; return YES; }
注意: iOS9以下还是会回调application:application openURL: sourceApplication: annotation: 这个方法, 所以这两个方法都得重写..
以上是关于iOS9 application:application openURL: sourceApplication: annotation: 方法不执行的主要内容,如果未能解决你的问题,请参考以下文章