码迷,mamicode.com
首页 > 移动开发 > 详细

支付宝回调app失败

时间:2014-12-30 13:39:24      阅读:701      评论:0      收藏:0      [点我收藏+]

标签:支付宝   回调   ios   

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!


支付宝回调app失败

标签:支付宝   回调   ios   

原文地址:http://blog.csdn.net/hmxhh/article/details/42264065

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!