沐道SDK集成文档

2019-05-29  本文已影响0人  Frankkkkk

一、系统要求

沐道SDK支持版本:iOS8.0+
接入方式:手动导入

二、接入准备

  1. APPID申请(安卓和iOS用同一套appId和scheme)

三、info.plist的配置:

1、权限的配置

<key>NSCameraUsageDescription</key> <string>"xxxx"希望访问您的相机,为了提供扫描二维码与照片拍摄服务</string> 
<key>NSContactsUsageDescription</key> <string>"xxxx"希望访问您的通讯录,为您和您朋友提供更好的优惠与服务</string> 
<key>NSLocationWhenInUseUsageDescription</key> <string>"xxxx"希望在使用期间访问您的位置,为了提供附近的优惠与服务</string> 
<key>NSMicrophoneUsageDescription</key> <string>"xxxx"需要您的同意,才能访问麦克风</string>
<key>NSPhotoLibraryAddUsageDescription</key> <string>"xxxx"需要您的同意,才能存储图片</string>
<key>NSPhotoLibraryUsageDescription</key> <string>"xxxx"希望访问您的相册,为了帮您实现上传照片识别功能</string>

2、LSApplicationQueriesSchemes的配置

<key>LSApplicationQueriesSchemes</key>
<array>
<string>taobao</string>
<string>alipay</string>
<string>alipays</string>
<string>alipayqr</string>
<string>wechat</string>
<string>weixin</string>
<string>mqq</string>
<string>mqqwpa</string>
<string>openapp.jdmobile</string>
</array>

四、导入SDK文件

1、普通依赖(可pod导入与本项目公用即可)

2、核心依赖
包含:FanbeiCreditSDK.frameworkFanbeiCreditSDKResource.bundleXGDependance文件夹,如下图所示:

手动导入的文件

五、支付宝SDK所需要的配置

import <AlipaySDK/AlipaySDK.h>
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
#pragma mark -下面的xxx是:第二步接入准备中,向沐道提交的AppURL Schemes
    if ([url.host isEqualToString:@"xxx"]) {
        [FanbeiCreditManager zmAuthenticateCompleteCallback];
    }
    
    //支付宝预授权代码
    if ([url.host isEqualToString:@"safepay"]) {
        //跳转支付宝钱包进行支付,处理支付结果
        [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
            NSLog(@"result = %@",resultDic);
            //支付宝回调通知
            [[NSNotificationCenter defaultCenter] postNotificationName:@"MUDAONotificationAlipayResult" object: resultDic];
        }];
    }
    
    return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(nonnull id)annotation {
#pragma mark -下面的xxx是:第二步接入准备中,向沐道提交的AppURL Schemes
    if ([url.host isEqualToString:@"xxx"]) {
        [FanbeiCreditManager zmAuthenticateCompleteCallback];
    }
    
    //支付宝预授权代码
    if ([url.host isEqualToString:@"safepay"]) {
        //跳转支付宝钱包进行支付,处理支付结果
        [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
            NSLog(@"result = %@",resultDic);
            //支付宝回调通知
            [[NSNotificationCenter defaultCenter] postNotificationName:@"MUDAONotificationAlipayResult" object: resultDic];
        }];
    }
    
    return YES;
}
    // 花吧SDK初始化
    [FanbeiCreditManager initWithAppId:@"申请的appid" appKey:@"申请的appkey" mobile:@"手机号,必传" appType:MuDaoAppTypeChannel environmentType:self.envType customAddr:@"自定义花吧服务器地址" didClickAlaJieBa:NO finish:^(BOOL License) {
        
        // License为YES,SDK初始化成功
        if (License) {
            // 1、使用花吧功能时,要配置Schema
            [FanbeiCreditManager configAppSchema:@"你的appSchema"];
            
            // 2、花吧SDK打开外部APP页面,设置的回调
            [FanbeiCreditManager backtrackAppFinish:^BOOL(UINavigationController * _Nonnull nav, NSDictionary * _Nonnull params) {
                if (nav) {
                    NSString *type = params[@"type"];
                    if ([type isEqualToString:@"detail"] && [params[@"orderId"] description].length) {   //跳App的订单详情页
                        //                        UIViewController *vc = [[CTMediator sharedInstance] action_selfSupportOrderDetailViewControllerWithOrderId:params[@"orderId"]];
                        //                        [nav pushViewController:vc animated:YES];
                        return YES;
                    }
                    if ([type isEqualToString:@"repayment"]) {   //跳App的还款页
                        //                        [[CTMediator sharedInstance] action_jumpToHuanViewControllerWithController:nav.topViewController];
                        return YES;
                    }
                }
                return NO;
            }];
            
            // 3、打开花吧相关页面
            [FanbeiCreditManager startFanbeiCredit:VC mobile:@"手机号" appToken:nil targetType:targetType params:@{}];

        } else {
            NSLog(@"授权失败");
        }
    }];

其中VC必须为后缀为.mm的控制器
.m文件可以直接改为.mm文件

2.借吧初始化:

      [FanbeiCreditManager initWithAppId:@"申请的AppId" appKey:@"申请的appKey" mobile:@"手机号" appType:MuDaoAppTypeChannel environmentType:_envType customAddr:nil didClickAlaJieBa:NO finish:^(BOOL License) {
          if (License) {
              [FanbeiCreditManager startFanbeiCredit:VC mobile:@"手机号"];
          } else {
              NSLog(@"授权失败");
          }
      }];

其中VC必须为后缀为.mm的控制器
.m文件可以直接改为.mm文件

六、常见问题

上一篇 下一篇

猜你喜欢

热点阅读