支付宝回调app失败
app迭代新版本,发现从支付宝支付完成后,返回客户端的方法不执行了
//支付宝客户支付端回调函数 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { //解析url,处理结果 [self parse:url application:application]; return YES; }
查找原因:新版本增加了友盟的分享功能,发现了下面方法
// 客户端回调接收方法 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [UMSocialSnsService handleOpenURL:url]; }
从方法名看,这两个方法的功能有些相似,看一下UIApplication.h文件里面这两个方法的申明:
//1
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url; // Will be deprecated at some point, please replace with application:openURL:sourceApplication:annotation:
//2 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation NS_AVAILABLE_IOS(4_2); // no equiv. notification. return NO if the application can't open for some reason
注意这句注释:
// Will be deprecated at some point, please replace with application:openURL:sourceApplication:annotation:
// 在某些时候,方法1将会被废弃,请用方法2代替。
那就用方法2代替吧,修改如下:
// 客户端回调接收方法,根据sourceApplication区别回调的应用,然后分区处理 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { if ([sourceApplication isEqualToString:@"com.alipay.iphoneclient"]) { [self parse:url application:application]; return YES; } else if ([sourceApplication isEqualToString:@"com.tencent.xin"]) { [self shareWX:url]; return YES; } return [UMSocialSnsService handleOpenURL:url]; }
that‘s all!
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。