React Native开发技巧

react-native-paysdk link到已有Cocoa

2017-05-26  本文已影响38人  言溪Lee

appdelegate相关配置

func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool {
     if let host = url.host {
         if host == "safepay" {
              return true
         } else if host == "pay"{//添加微信支付代理
                return WXApi.handleOpenURL(url, delegate: WXApiManager.sharedManager())
            }
         }
      return true
 }
//iOS 9之前
 func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
      if let host = url.host {
            if host == "safepay" {
                AlipaySDK.defaultService().processAuth_V2Result(url, standbyCallback: { (resultDic) in
                    DLog("支付宝返回的授权结果信息\(resultDic)")
                })
                AlipaySDK.defaultService().processOrderWithPaymentResult(url, standbyCallback: { (resultDic) in
                    DLog("支付宝返回的支付结果信息\(resultDic)")
                })
            }else if host == "platformapi" {
                AlipaySDK.defaultService().processAuthResult(url, standbyCallback: { (resultDic) in
                    DLog("支付宝platform返回的授权结果信息\(resultDic)")
                })
            }else if host == "pay"{
                return WXApi.handleOpenURL(url, delegate: WXApiManager.sharedManager())
            }
        } else {
            return false
        }
        return true
 }
//iOS 9之后
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
        if let host = url.host {
            if host == "safepay" {
                AlipaySDK.defaultService().processAuth_V2Result(url, standbyCallback: { (resultDic) in
                    DLog("支付宝返回的授权结果信息\(resultDic)")
                })
                AlipaySDK.defaultService().processOrderWithPaymentResult(url, standbyCallback: { (resultDic) in
                    DLog("支付宝返回的支付结果信息\(resultDic)")
                })
            }else if host == "platformapi" {
                AlipaySDK.defaultService().processAuthResult(url, standbyCallback: { (resultDic) in
                    DLog("支付宝platform返回的授权结果信息\(resultDic)")
                })
            }else if host == "pay"{
                return WXApi.handleOpenURL(url, delegate: WXApiManager.sharedManager())
            }
        }
        return true
    }

最近测试接口遇到的问题

上一篇下一篇

猜你喜欢

热点阅读