objective-c - ios端集成支付宝的手机网站支付转APP支付,无法调起H5
迷茫
迷茫 2017-05-02 09:37:04
0
0
720

本人最近在对接支付宝 SDK 实现移动支付功能。从官网下了最新的DEMO,配置好参数以后,运行正常。然后按照教程一步步集成到自己的项目中去,该注意的也都注意了,编译OK。因手机已经安装了支付宝客户端,因此需要在Appdelegate 中获取同步结果,代码如下(Swift):

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {

if (url.host! as String) == "safepay" {
    // 支付跳转支付宝钱包进行支付,处理支付结果
    AlipaySDK.defaultService().processOrderWithPaymentResult(url, standbyCallback: { (resultDic) in
        print("result = \(resultDic)")
    })
}
return true

}

// NOTE: 9.0以后使用新API接口
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {

if (url.host! as String) == "safepay" {
    // 支付跳转支付宝钱包进行支付,处理支付结果
    AlipaySDK.defaultService().processOrderWithPaymentResult(url, standbyCallback: { (resultDic: [NSObject : AnyObject]!) in
        print("result = \(resultDic)")
    })
}
return true

}
真机运行后,跳转到支付宝支付成功,再跳回到自己的 App 时,控制台能够打印出同步结果(状态是9000支付成功的),但程序直接 crash,停在 AlipaySDK.defaultService().processOrderWithPaymentResult 方法中,控制台就显示(lldb)。

随后我尝试将 AlipaySDK.defaultService().processOrderWithPaymentResult 方法屏蔽掉,运行就正常了,不会崩溃。我又在另外一台真机上测试,因这台真机没有安装支付宝客户端,所以在H5中完成支付后会在:

AlipaySDK.defaultService().payUrlOrder(orderString as String, fromScheme: appScheme, callback: { (resultDic) in

        print(resultDic)
    })

方法中获取同步结果,但这次控制台没有打印同步结果,直接 crash。
这说明只要我一调用获取同步结果的方法就会 crash。无奈我又新建一个测试的 Swift 项目,同样的方法集成支付宝 SDK,一样的代码,结果发现运行正常,压根不会有之前的崩溃现象!我怀疑会不会是和别的第三方库发生冲突了,但是之前也遇到过两个三方库冲突,一般都是重定义的问题,编译也不会通过。

实在找不出问题在哪,求这里的大大们有没有遇到过我这个问题,跪谢!

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

répondre à tous(0)
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!