时间:2021-08-05 08:31:11 | 栏目:iOS代码 | 点击:次
如果是iOS 9.0之前,处理微信回调时,首先在APPDelegate中写如下的代码:
//iOS 9.0 之前的处理方法不保证正确,如有错误还望指正 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { if ([url.host isEqualToString:@"safepay"]) { [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:nil]; return YES; } return YES; }
如果是iOS 9以上,那么写下面这段代码:
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { if ([url.host isEqualToString:@"safepay"]) { [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:nil]; return YES; } return YES; }
最后再实现-(void) onResp:(BaseResp*)resp
该方法来接收微信的回调.