一、系统要求
沐道SDK支持版本:iOS8.0+
接入方式:手动导入
二、接入准备
- APPID申请(安卓和iOS用同一套appId和scheme)
- 向沐道申请APPID和APPKEY
- 向沐道提交App的
Bundle ID
- 向沐道提交App的
URL Schemes
(第五步会用到)
URL Schemes
三、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导入与本项目公用即可)
'AFNetworking', '~> 3.2.1'
'Masonry', '~> 1.1.0'
'SDWebImage', '~> 4.4.2'
2、核心依赖
包含:FanbeiCreditSDK.framework
、FanbeiCreditSDKResource.bundle
、XGDependance文件夹
,如下图所示:

五、支付宝SDK所需要的配置
-
在 Build Phases 选项卡的 Link Binary With Libraries 中,增加以下依赖:
支付宝依赖
-
在AppDelegate.m文件中,增加头文件引用
import <AlipaySDK/AlipaySDK.h>
- 在代码中增加URL跳转
- (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初始化
在按钮点击后(SDK调起)实现:
1.花吧初始化:
// 花吧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文件
六、常见问题
- 发送的sdk为真机版本,所以请真机运行
- SDK授权失败时,务必仔细查看API和检查入参!
网友评论