iOS接入文档
资源下载及说明
- 国内SDK资源 ios_platform_sdk.zip
- 海外SDK资源 ios_global_platform_sdk.zip
通用资源(必须引入)
将ios_platform_sdk/access_core 文件夹下的所有资源导入工程中(基础,)
模块资源说明
国内SDK模块
- libplatform-account-sdk.a —— 账号模块(SDK核心模块,)
- libplatform-block-account.a —— 国内登录模块()
libplatform-pay-sdk.a —— 支付模块
libplatform-applelogin.a —— 苹果登录模块
libplatform-wechatlogin.a —— 微信登录模块
libplatform-qqlogin.a —— QQ登录模块
libplatform-crashsight.a —— CrashSight模块
libplatform-bugly.a —— Bugly模块
libplatform-qqshare.a —— QQ分享模块
libplatform-wechatshare.a —— 微信分享模块
libplatform-appsflyer.a —— appsflyer模块
libplatform-analysys.a —— 方舟模块
海外SDK模块
libplatform-account-sdk.a —— 账号模块(SDK核心模块,)
libplatform-global-account.a ---- 海外登录模块()
libplatform-alhelpservice.a —— 客服模块
libplatform-analysys.a —— 方舟模块
libplatform-applelogin.a—— 苹果登录模块
libplatform-appsflyer.a —— AppsFlyer模块
libplatform-cloudlogproducer.a —— 网络报送模块
libplatform-crashsight.a —— CrashSight模块
libplatform-facebooklogin.a —— FaceBook登录模块
libplatform-facebookshare.a —— FaceBook分享模块
libplatform-firebase.a —— Firebase模块
libplatform-googlelogin.a —— Google登录模块
libplatform-openinstall.a —— Openinstall模块
libplatform-pay-sdk.a —— ApplePay模块
模块引入及配置说明()
- 在引入模块之前务必在项目Info->URL Types->URL Schemes 设置 accesssdk+channelId,否则将导致初始化失败!
- channelId需跟运营获取
注意
如果同时接入QQ登录模块、QQ分享模块,对应的模块文件夹libs只需引入一个其中一个即可,微信登录与微信分享模块、Facebook登录模块与Facebook分享模块同理。
需在info里把对应的 View controller-based status bar appearance 权限设置为 YES
SDK接入环境搭建
系统framework引入
请在游戏工程中添加以下系统Framework
StoreKit.framework
WebKit.framework
Network.framework
SystemConfiguration.framework
AppTrackingTransparency.framework
AdSupport.framwork
CoreTelephony.framework
iAd.framework
AdServices.framework
libz.tbd
libc++.tbd
libresolv.tbd
注意
如果是引入国内登录模块libplatform-block-account.a 需再次导入libplatform-block-account依赖的三方库
引入通用资源到工程中
通用资源引入方法
将通用资源拖到工程面板中,在弹出选择框里按照图1-1进行选择(推荐勾选Copy items if needed)
引入配置文件
- 文件名:access.config
- 配置文件引入方法: 同引入通用资源
- 资源通过运营获取
项目参数配置
- info.plist文件中添加如下配置(用来申请获取IDFA权限:描述一般为:'游戏名'想访问您的设备标识符(IDFA)用于广告追踪),如图所示:
- 点击项目target,选择Build Setting tab页,搜索Other Linker Flags,双击后点击加号,添加为-ObjC即可,已经添加过不用再添加。效果如图1-2所示
- 在Info.plist中配置Privacy - Photo Library Additions Usage Description项,类型选择String,值为:将要访问您的相册
- 在Info.plist中配置Privacy - Photo Library Usage Description项,类型选择String,值为:将要保存截图到相册
- 在Info.plist中配置http网络访问的支持,配置App Transport Security Settings项,类型为Dictoionary,然后配置子项Allow Arbitrary Loads,类型为Boolean,值为Yes
AccessCore SDK基础功能
在配置好接入环境,导入SDK库和配置文件后,您即可开始接入SDK各功能
提示
SDK接口国内模块跟海外模块接口通用,如有标注是(海外)只能海外调用,国内模块调用无效果
SDK初始化
导入SDK头文件
#import <platform_core_sdk/platform_core_sdk.h>
在appDelegeta.h中继承AccessCoreAppDelegate,如下图所示:
- SDK初始化 delegate需要 HLSystemDelegate,HLPaymentDelegate,HLAccountDelegate,HLShareCallback 代理回调按需接入,具体方法可以见后续说明
@interface SDKDelegate : AccessCoreAppDelegate<HLSystemDelegate,HLPaymentDelegate,HLAccountDelegate,HLShareCallback>
@interface AppDelegate ()
@end
@implementation SDKDelegate
@synthesize window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = [[DemoController alloc]init];
[self.window makeKeyAndVisible];
[AccessCoreSdk shareAccessCoreSdkManage].systemDelegate = self;
[AccessCoreSdk shareAccessCoreSdkManage].paymentDelegate = self;
[AccessCoreSdk shareAccessCoreSdkManage].accountDelegate = self;
[AccessCoreSdk shareAccessCoreSdkManage].shareDelegate = self;
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
代理回调方法
@protocol HLSystemDelegate <NSObject>
/**
* 初始化成功
*/
- (void)initSuccess:(AccessInitResult *)initResult;
/**
* 初始化失败
*/
- (void)initFailed;
@end
@protocol HLPaymentDelegate <NSObject>
/**
* 支付成功
*/
- (void)paySuccess;
/**
* 支付失败
* @param error 错误信息
*/
- (void)payError:(NSError *)error;
@optional
/**
* 获取商品信息
* @param info 商品信息
*/
- (void)payGoodsList:(NSArray <AccessGoodsInfo *>*)info;
/**
* 获取商品获取失败
*/
- (void)payGpodsListFail;
@end
@protocol HLAccountDelegate <NSObject>
/**
* 登录成功
* @param accountInfo 登录成功信息
*/
- (void)loginSuccess:(AccessLoginInfo *)accountInfo;
/**
* 切换小号成功
* @param refreshAccountInfo 登录成功信息
*/
- (void)refreshUser:(AccessLoginInfo *)refreshAccountInfo;
/**
* 登录失败
*/
- (void)loginFailure;
/**
* 登出
*/
- (void)logout;
@end
@protocol HLShareCallback <NSObject>
/**
* 分享成功
*/
- (void)shareSucceeded:(BOOL)result;
/**
* 分享失败
*/
- (void)shareFailed:(BOOL)result;
- AccessInitResult 对应的属性
@property (nonatomic, strong) NSString *channel; //渠道
@property (nonatomic, assign) int gameId; // 游戏ID
@property (nonatomic, assign) int channelId; // 渠道ID
- AccessLoginInfo 对应的属性
@property (nonatomic, assign) long long uid;
@property (nonatomic, strong) NSString *accessToken; // 用户授权token
@property (nonatomic, strong) NSString *channel; // 渠道
@property (nonatomic, strong) NSString *channelUid DEPRECATED_MSG_ATTRIBUTE("此属性已弃用~"); // 渠道用户ID
@property (nonatomic, strong) NSString *serverArea; // 区域
@property (nonatomic, strong) NSMutableDictionary *extendInfo; //扩展参数
生命周期接口
将SDK需要的生命周期方法进行实现,需要注意调用super 父类方法。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
[super applicationWillResignActive:application];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
[super applicationDidEnterBackground:application];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
[super applicationWillEnterForeground:application];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
[super applicationDidBecomeActive:application];
}
- (void)applicationWillTerminate:(UIApplication *)application {
[super applicationWillTerminate:application];
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [super application:app openURL:url options:options];
};
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
[super application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[super application:application didReceiveLocalNotification:notification];
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[super application:application didRegisterUserNotificationSettings:notificationSettings];
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler{
[super application:application handleActionWithIdentifier:identifier forRemoteNotification:userInfo completionHandler:^{
}];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
[super application:app didFailToRegisterForRemoteNotificationsWithError:err];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[super application:application didReceiveRemoteNotification:userInfo];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
[super application:application supportedInterfaceOrientationsForWindow:window];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> * __nullable restorableObjects))restorationHandler{
return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}
### SDK登录接口
```Objective-C
/**
* 登录
*/
-(void)login;
[[AccessCoreSdk shareAccessCoreSdkManage] login];//此接口会触发登录回调
注:在未登出的情况下不得二次调用登录接口,以免游戏出现多次回调
SDK登出接口
/**
* 登出
*/
-(void)logout;
[[AccessCoreSdk shareAccessCoreSdkManage] logout];
注:登出成功后会触发登出回调接口(海外SDK调用无效)
SDK上报接口
/**
* 上报用户信息至SDK
* @param type 上报的数据类型
* @param info 用户信息,不能为空
*/
- (void)report:(EventType)type data:(AccessPlayerInfo *)info;
- (void)setUserExtDataType:(EventType)type data:(AccessPlayerInfo *)userExtData DEPRECATED_MSG_ATTRIBUTE("Please use -report:info:");
/**
* 自定义数据报送
* @param action 事件名称,不可为空或者null
* @param gameinfo 报送的扩展信息
*/
- (void)gameDataReport:(NSString *)action withGameInfo:(NSMutableDictionary *)gameinfo DEPRECATED_MSG_ATTRIBUTE("Please use AccessPlayerInfo Class 来进行自定义报送。");
AccessPlayerInfo *model = [AccessPlayerInfo new];
model.zone_id = @"12312";
model.zone_name = @"大区测试";
model.server_id = @"11212";
model.server_name = @"服务器名测试";
model.role_id = @"229";
model.role_name = @"测试组";
model.role_level = @"10";
model.party_name = @"10";
model.vip = @"100";
model.balance = @"200";
model.extene_action = @"test_action";
[model addExtra:@"intKey" intValue:55];
[model addExtra:@"longLongKey" doubleValue:66786658787676];
[model addExtra:@"stringKey" NSStringValue:@"Hello111"];
[model addExtra:@"test1" NSStringValue:@"11"];
[model addExtra:@"test2" NSStringValue:@"22"];
[model addExtra:@"test3" NSStringValue:@"33"];
[model addExtra:@"gameResourceUrl" NSStringValue:@"tcp@github.com@9988"];
[model addExtra:@"gameLoginServerUrl" NSStringValue:@"http@platforrrrm.hoolai.com/test/index@9900"];
[model addExtra:@"gameServerUrl" NSStringValue:@"https@191.45.90.89@8087"];
[model addExtra:@"userLogo" NSStringValue:@"https%3A%2F%2Fimg2.baidu.com%2Fit%2Fu%3D3172931140%2C714963860%26fm%3D253%26fmt%3Dauto%26app%3D138%26f%3DJPEG%3Fw%3D500%26h%3D500"];
[model addExtra:@"action11" NSStringValue:@"222"];
[model addExtra:@"44" intValue:55];
[[AccessCoreSdk shareAccessCoreSdkManage] report:<EventType> data:model];
- AccessPlayerInfo对应的参数及方法:
@property (nonatomic, strong) NSString *server_name; //服务名称
@property (nonatomic, strong) NSString *zone_id; // 区ID
@property (nonatomic, strong) NSString *zone_name;//区名称
@property (nonatomic, strong) NSString *server_id;//服务ID
@property (nonatomic, strong) NSString *role_id;//角色ID
@property (nonatomic, strong) NSString *role_name;//角色名称
@property (nonatomic, strong) NSString *role_level;//角色等级
@property (nonatomic, strong) NSString *party_name;//帮派名
@property (nonatomic, strong) NSString *vip; //vip
@property (nonatomic, strong) NSString *balance;//余额
@property (nonatomic, strong) NSString *phylum;//分类/步骤
@property (nonatomic, strong) NSString *classfield;//行为结果
@property (nonatomic, strong) NSString *extene_action;//点名称
@property (nonatomic, strong, readonly) NSString *extra DEPRECATED_MSG_ATTRIBUTE("请使用 addExtra: 来进行自定义报送。");//扩展信息 拼接___示例:@"key:value,key:value...."
/**
* 自定义数据报送
* @param key 事件名称,不可为空或者null
* @param val 报送的信息 类型:int
*/
- (void)addExtra:(NSString*)key intValue:(int)val;
/**
* 自定义数据报送
* @param key 事件名称,不可为空或者null
* @param val 报送的信息 类型:double
*/
- (void)addExtra:(NSString*)key doubleValue:(double)val;
/**
* 自定义数据报送
* @param key 事件名称,不可为空或者null
* @param val 报送的信息 类型:NSString
*/
- (void)addExtra:(NSString*)key NSStringValue:(NSString *)val;
- 请使用 AccessPlayerInfo 对应 addExtra:来进行自定义报送。 自定义报送方式代码参考示例
AccessPlayerInfo *model = [AccessPlayerInfo new];
[model addExtra:@"intKey" intValue:55];
[model addExtra:@"longLongKey" doubleValue:66786658787676];
[model addExtra:@"stringKey" NSStringValue:@"Hello111"];
model.extene_action = @"test_open_app";
[[AccessCoreSdk shareAccessCoreSdkManage] report:ACCESS_CUSTOMER_ACTION data:model];
支付接口
/**
* 获取商品信息
*/
- (void)queryGoodsInfo;
/**
* 开始支付
*/
- (void)pay:(AccessBeginPayInfo *)goodsModel;
>注: queryGoodsInfo 方法调用对应返回的参数是在 HLPaymentDelegate
@optional
/**
* 获取商品信息
* @param info 商品信息
*/
- (void)payGoodsList:(NSArray <AccessGoodsInfo *>*)info;
/**
* 获取商品获取失败
*/
- (void)payGpodsListFail;
- AccessGoodsInfo 对应的属性
@property (nonatomic, strong) NSString *region; //地区
@property (nonatomic, strong) NSString *currency; //货币
@property (nonatomic, strong) NSString *symbol; //商品符号
@property (nonatomic, strong) NSString *itemId; //商品id
@property (nonatomic, strong) NSString *itemName; //商品名
@property (nonatomic, strong) NSString *itemCount; //商品数量
@property (nonatomic, strong) NSString *itemPrice; //商品价格
@property (nonatomic, strong) NSString *showTag; //展示tag(格式化价格)
- pay: 方法调用应传入AccessBeginPayInfo对应的属性:
@property (nonatomic, assign) int price; //价格
@property (nonatomic, strong) NSString *finalPrice DEPRECATED_MSG_ATTRIBUTE("此属性已弃用~"); //支付价格
@property (nonatomic, strong) NSString *productIdentifier;//商品ID
@property (nonatomic, strong) NSString *currencyLocale; //货币区域
@property (nonatomic, strong) NSString *payChannel DEPRECATED_MSG_ATTRIBUTE("此属性已弃用~");//支付渠道
@property (nonatomic, strong) NSString *gameInfo; //游戏信息
@property (nonatomic, strong) NSString *notifyUrl; //回调url
CDK接口
/**
* 获取CDK接口
* activityType 活动类型
* activityDataType 创建AccessActivityDataInfo 传入cdk需要的code
*/
- (void)accessParticipate:(ACTIVITY_TYPE)activityType ActivityDataType:(AccessActivityDataInfo*)activityDataType;
- CDK需要的参数 ACTIVITY_TYPE枚举参数
typedef enum _ACTIVITY_TYPE {
ACCESS_NO_ACTIVITY = 0, // 没有活动
ACCESS_CD_KEY, // cdk 类型
}ACTIVITY_TYPE;
- AccessActivityDataInfo对应的属性:
@interface AccessActivityDataInfo : NSObject
@property (nonatomic, strong) NSString *code;
@end
分享接口
/*
* 提示: 分享只能单选一种分享模式,文案跟图片不能一起分享(懂球帝分享除外)。创建AccessShareInfo,给对应的属性赋值即可。
* type 分享平台类型
* object 分享平台的内容
*/
- (void)shareType:(THREE_SHARE_TYPE)type shareObject:(AccessShareInfo *)object;
- AccessShareInfo 对应的属性 注: 懂球帝分享无相关代理回调
typedef enum _THREE_SHARE_TYPE {
ACCESS_SCENESESSION = 0, // 微信好友
ACCESS_SCENETIMELINE, // 微信朋友圈
ACCESS_SCENEQQTOSESSION, // QQ好友
ACCESS_SCENEQQTOQZONE, // QQ空间
ACCESS_DONGQIUDI, // 懂球帝
ACCESS_FACEBOOK_LINK, // facebook分享链接(海外)
ACCESS_FACEBOOK_IMAGE, // facebook分享图片(海外)
ACCESS_FACEBOOK_VIDEO, // facebook分享视频(海外)
ACCESS_APPLE_SHARE // apple分享(海外)
} THREE_SHARE_TYPE;
@interface AccessDongQiuDiShare : NSObject
@property (nonatomic, strong) NSString *circleID; // 圈子
@property (nonatomic, strong) NSString *title; // 标题
@property (nonatomic, strong) NSString *content; // 分享的内容
@property (nonatomic, strong) NSString *scheme; // 自己项目scheme,做跳转使用
@property (nonatomic, strong) NSArray<NSString *> *assetIDs; // 图片或视频地址(相册)
@end
@interface AccessShareInfo : NSObject
@property (nonatomic, strong) NSString *title; // 标题
@property (nonatomic, strong) NSString *imagePath; // 图片/视频地址 注意:如果是Facebook照片分享 照片大小必须小于 12MB 如果是Facebook视频分享 视频大小必须小于 50MB。
@property (nonatomic, strong) NSString *linkPath; // 分享链接地址
@property (nonatomic, strong) AccessDongQiuDiShare *shareDongQiuDi;//懂球帝分享
@end
打开账号管理中心(海外)
/*
*打开账号管理中心(海外)
*/
- (void)openAccountCenter;
打开客服中心(海外)
/*
*打开客服中心(海外)
*/
- (void)openService;
国内必接模块
Apple Pay模块
引入当前libplatform-pay文件夹
并配置相关ApplePay登录权限 在工程中配置苹果登陆选项,如图所示:
CrashSight模块
引入当前access_crashsight文件夹
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
- 添加依赖库SystemConfiguration.framework
- Security.framework
- libz.dylib 或 libz.tdb
- libc++.dylib 或 libc++.tdb(不报错可不添加)
接入结果测试
a. 开启Debug模式,初始化CrashSight,并给定合适的配置参数
b. 联网上报:检查测试设备日志中是否打印“begin to upload <CSAnalyticsLogic” 或者 “cmd: 641”
c. 崩溃捕获:检查测试设备日志中是否打印“Handle the crash scene in callback”
d. 上报异常:检查测试设备日志中是否打印“begin to upload <CSCrashLogic” 或者 “cmd: 631”
Apple登录模块
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
- 并配置相关Apple登录权限 在工程中配置苹果登陆选项,如图所示:
添加系统依赖库
- AuthenticationServices.framework
QQ登录模块
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
添加系统依赖库
- CoreGraphics.framework
- CoreTelephony.framework
- Foundation.framework
- libc++.tbd
- libiconv.tbd
- libsqlite3.tbd
- Security.framework
- SystemConfiguration.framework
- WebKit.framework
在Info.plist 添加LSApplicationQueriesSchemes 添加相应的白名单
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tim</string>
<string>mqq</string>
<string>mqqapi</string>
<string>mqqbrowser</string>
<string>mttbrowser</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqopensdkapiV2</string>
<string>mqqopensdkapiV4</string>
<string>mqzone</string>
<string>mqzoneopensdk</string>
<string>mqzoneopensdkapi</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapiV2</string>
<string>mqqapiwallet</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdkavatar</string>
<string>mqqopensdkminiapp</string>
<string>mqqopensdkdataline</string>
<string>mqqgamebindinggroup</string>
<string>mqqopensdkgrouptribeshare</string>
<string>tencentapi.qq.reqContent</string>
<string>tencentapi.qzone.reqContent</string>
<string>mqqthirdappgroup</string>
<string>mqqopensdklaunchminiapp</string>
<string>mqqopensdkproxylogin</string>
<string>mqqopensdknopasteboard</string>
</array>
微信登录模块
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
在Info.plist 添加LSApplicationQueriesSchemes 添加相应的白名单 微信对应的白名单:
- weixinULAPI
- weixin
<key>LSApplicationQueriesSchemes</key>
<array>
<string>wechat</string>
<string>weixinULAPI</string>
<string>weixin</string>
</array>
国内可选模块接入
Bugly模块
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
添加依赖库
- SystemConfiguration.framework
- Security.framework
- libz.dylib 或 libz.tbd
- libc++.dylib 或 libc++.tbd
懂球帝分享
示例代码
[[AccessCoreSdk shareAccessCoreSdkManage]shareType:ACCESS_DONGQIUDI shareObject:[self dongqiudiShare]];
- (AccessShareInfo *)dongqiudiShare{
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
// UIImage *image = [UIImage imageNamed:@"res2.jpg"];
NSURL *videoURL = [NSURL fileURLWithPath:[NSBundle.mainBundle pathForResource:@"res3" ofType:@"MP4"]];
__block AccessShareInfo *sharemodel = [AccessShareInfo new];
__block PHObjectPlaceholder *imagePlaceholder;
__block PHObjectPlaceholder *videoPlaceholder;
NSMutableArray<NSString *> *identifiers = [NSMutableArray array];
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
// imagePlaceholder = [PHAssetCreationRequest creationRequestForAssetFromImage:image].placeholderForCreatedAsset;
videoPlaceholder = [PHAssetCreationRequest creationRequestForAssetFromVideoAtFileURL:videoURL].placeholderForCreatedAsset;
} completionHandler:^(BOOL success, NSError * _Nullable error) {
NSLog(@"save result = %@, error = %@", @(success), error);
if (!success) {
return;
}
// if (imagePlaceholder) {
// [identifiers addObject:imagePlaceholder.localIdentifier];
// }
if (videoPlaceholder) {
[identifiers addObject:videoPlaceholder.localIdentifier];
}
NSLog(@"identifiers = %@", identifiers);
AccessDongQiuDiShare *dognqiudi = [AccessDongQiuDiShare new];
dognqiudi.circleID = @"123";
dognqiudi.title = @"测试分享标题";
dognqiudi.content = @"我是分享内容";
dognqiudi.scheme = @"demo";
dognqiudi.assetIDs = identifiers;
sharemodel.shareDongQiuDi = dognqiudi;
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
return sharemodel;
}
微信分享模块
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
在Info.plist 添加LSApplicationQueriesSchemes 添加相应的白名单 微信对应的白名单:
- weixinULAPI
- weixin
<key>LSApplicationQueriesSchemes</key>
<array>
<string>wechat</string>
<string>weixinULAPI</string>
<string>weixin</string>
</array>
示例代码
// 微信好友
[[AccessCoreSdk shareAccessCoreSdkManage]shareType:ACCESS_SCENESESSION shareObject:[self startShareType]];
//微信朋友圈
[[AccessCoreSdk shareAccessCoreSdkManage]shareType:ACCESS_SCENETIMELINE shareObject:[self startShareType]];
- (AccessShareInfo *)startShareType{
UIImage *iamge = [UIImage imageNamed:@"res2.jpg"];
NSString *path_sandox = NSHomeDirectory();
NSString *imagePath = [path_sandox stringByAppendingString:@"/Documents/test.png"];
[UIImagePNGRepresentation(iamge) writeToFile:imagePath atomically:YES];
AccessShareInfo *sharemodel = [AccessShareInfo new];
if (self.shareText.text.length){
sharemodel.title = self.shareText.text;
}else{
sharemodel.imagePath = imagePath;
}
return sharemodel;
}
QQ分享模块
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
添加系统依赖库
- CoreGraphics.framework
- CoreTelephony.framework
- Foundation.framework
- libc++.tbd
- libiconv.tbd
- libsqlite3.tbd
- Security.framework
- SystemConfiguration.framework
- WebKit.framework
在Info.plist 添加LSApplicationQueriesSchemes 添加相应的白名单
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tim</string>
<string>mqq</string>
<string>mqqapi</string>
<string>mqqbrowser</string>
<string>mttbrowser</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqopensdkapiV2</string>
<string>mqqopensdkapiV4</string>
<string>mqzone</string>
<string>mqzoneopensdk</string>
<string>mqzoneopensdkapi</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapiV2</string>
<string>mqqapiwallet</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdkavatar</string>
<string>mqqopensdkminiapp</string>
<string>mqqopensdkdataline</string>
<string>mqqgamebindinggroup</string>
<string>mqqopensdkgrouptribeshare</string>
<string>tencentapi.qq.reqContent</string>
<string>tencentapi.qzone.reqContent</string>
<string>mqqthirdappgroup</string>
<string>mqqopensdklaunchminiapp</string>
<string>mqqopensdkproxylogin</string>
<string>mqqopensdknopasteboard</string>
</array>
示例代码
// QQ好友
[[AccessCoreSdk shareAccessCoreSdkManage]shareType:ACCESS_SCENEQQTOSESSION shareObject:[self startShareType]];
//QQ空间
[[AccessCoreSdk shareAccessCoreSdkManage]shareType:ACCESS_SCENEQQTOQZONE shareObject:[self startShareType]];
- (AccessShareInfo *)startShareType{
UIImage *iamge = [UIImage imageNamed:@"res2.jpg"];
NSString *path_sandox = NSHomeDirectory();
NSString *imagePath = [path_sandox stringByAppendingString:@"/Documents/test.png"];
[UIImagePNGRepresentation(iamge) writeToFile:imagePath atomically:YES];
AccessShareInfo *sharemodel = [AccessShareInfo new];
if (self.shareText.text.length){
sharemodel.title = self.shareText.text;
}else{
sharemodel.imagePath = imagePath;
}
return sharemodel;
}
appsflyerr模块
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
导入系统依赖库
- 添加AdSupport.framework
- iAd.framework
从您的营销人员那里获取OneLink子域
- 在Xcode中,单击您的项目
- 单击项目目标(请参阅下面的屏幕截图)
- 切换到功能选项卡
- 打开关联域
- 添加您从营销人员那里获得的子域
- 格式为applinks:xxxxxxxxx.onelink.me
方舟报送模块
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
使用方式 参考 SDK上报接口
- (void)report:(EventType)type data:(AccessPlayerInfo *)info;
- (void)setUserExtDataType:(EventType)type data:(AccessPlayerInfo *)userExtData DEPRECATED_MSG_ATTRIBUTE("Please use -report:info:");
网络探测模块
导入ios-platform-cloudlogproducer所有文件
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
BuiID Phases - > Link binary With Libraries 下面将Status->Required更改为Optional
功能实现同上报接口一致。具体规则请参考:客户端数据上报
头条报送模块
导入ios-platform-ttsdk所有文件
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
- 创建Build->New Copy Files Phase->Destination 创建完成按图设置 Frameworks, 并将拖入的 framework 包加入到 Name 目录下:
海外必接模块
Apple Pay模块
引入当前libplatform-pay文件夹
并配置相关ApplePay登录权限 在工程中配置苹果登陆选项,如图所示:
CrashSight模块
引入当前access_crashsight文件夹
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
添加依赖库
- SystemConfiguration.framework
- Security.framework
- libz.dylib 或 libz.tdb
- libc++.dylib 或 libc++.tdb(不报错可不添加)
接入结果测试
a. 开启Debug模式,初始化CrashSight,并给定合适的配置参数
b. 联网上报:检查测试设备日志中是否打印“begin to upload <CSAnalyticsLogic” 或者 “cmd: 641”
c. 崩溃捕获:检查测试设备日志中是否打印“Handle the crash scene in callback”
d. 上报异常:检查测试设备日志中是否打印“begin to upload <CSCrashLogic” 或者 “cmd: 631”
Apple登录模块
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
并配置相关Apple登录权限 在工程中配置苹果登陆选项,如图所示:
添加系统依赖库
- AuthenticationServices.framework
Google登录模块
引入当前ios-platform-googlelogin文件夹对应的模块及libs里面依赖的资源库,GoogleSignIn.bundle需要引入主tag。
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
创建Build->New Copy Files Phase->Destination 创建完成按图设置 Frameworks, 并将拖入的 framework 包加入到 Name 目录下:
在info.plist添加URLSchemes 。CLIENT_ID是以com.googleusercontentxxxxxxxx-xxxxxxx格式,参数具体找运营同学获取。
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>YOUR_DOT_REVERSED_IOS_CLIENT_ID</string>
</array>
</dict>
</array>
FaceBook登录模块
引入当前ios-platform-facebooklogin文件夹对应的模块及libs里面依赖的资源库 注意:如果工程中引入了libplatform-facebookshare.a 分享模块,对应的ios-platform-facebooklogin/libs 或 ios-platform-facebookshare/libs 文件夹中依赖库只需引用一个即可。否则会有冲突。
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
导入系统依赖库
- Accelerate.framework
创建Build->New Copy Files Phase->Destination 创建完成按图设置 Frameworks, 并将拖入的 framework 包加入到 Name 目录下:
创建SwiftFile Bridging-Header桥接文件放在工程中
在info.plist添加相应的白名单
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
海外可选模块接入
FaceBook分享模块
引入当前ios-platform-facebookshare文件夹对应的模块及libs里面依赖的资源库 注意:如果工程中引入了libplatform-facebookshare.a 分享模块,对应的ios-platform-facebookshare/libs 或 ios-platform-facebooklogin/libs 文件夹中依赖库只需引用一个即可。否则会有冲突。
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
导入系统依赖库
- Accelerate.framework
创建Build->New Copy Files Phase->Destination 创建完成按图设置 Frameworks, 并将拖入的 framework 包加入到 Name 目录下:
创建SwiftFile Bridging-Header桥接文件放在工程中
在info.plist添加相应的白名单
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
网络探测模块
导入ios-platform-cloudlogproducer文件夹
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
BuiID Phases - > Link binary With Libraries 下面将Status->Required更改为Optional
功能实现同上报接口一致。具体规则请参考:客户端数据上报
appsflyerr模块
导入ios-platform-appsflyer文件夹
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
导入系统依赖库
- AdSupport.framework
- iAd.framework
从您的营销人员那里获取OneLink子域
1.在Xcode中,单击您的项目。
2.单击项目目标(请参阅下面的屏幕截图)。
3.切换到功能选项卡。
4.打开关联域。
5.添加您从营销人员那里获得的子域。
6. 格式为applinks:xxxxxxxxx.onelink.me。
方舟报送模块
- 导入ios-platform-analysys文件夹
接入方式:
- 拖拽当前文件夹到Xcode工程内(请勾选"Copy items if needed"选项)
使用方式 参考 SDK上报接口
- (void)report:(EventType)type data:(AccessPlayerInfo *)info;
- (void)setUserExtDataType:(EventType)type data:(AccessPlayerInfo *)userExtData DEPRECATED_MSG_ATTRIBUTE("Please use -report:info:");
客服模块
- 导入ios-platform-alhelpservice文件夹
设置SDK所需权限, 在项目工程的 info.plist 中增加1个权限: Privacy - Photo Library Usage Description 需要访问您的相册权限,才能将图片上传反馈给客服
注意:ios-platform-alhelpservice/libs对应的AIHelpSupportSDK.bundle资源需要放到xcode工程下的主tag下面
调用方法示例:
[[AccessCoreSdk shareAccessCoreSdkManage]openService];
Firebase模块
导入ios-platform-firebase文件夹
xcode配置如下所示: 在info.plist FirebaseAppDelegateProxyEnabled 设置为 no
Background Modes 进行勾选
导入GoogleService-info.plist 文件需要像运营同学获取
OpenInstall模块
导入ios-platform-openinstall文件夹
在Info.plist文件中配置appKey键值对, com.openinstall.APP_KEY xxxxxx
- 一键拉起 openinstall 通过标准的 Scheme(iOS<9),Universal Links(iOS≥9)技术,在 app 已安装的情况下,从各种浏览器(包括微信、QQ、新浪微博、钉钉等主流社交软件的内置浏览器)拉起 App 并传递动态参数。
- 集成通用链接(Universal Links),只适用于iOS9以上
- 到苹果开发者网站,为当前的 AppID 开启关联域名(Associated Domains)服务:
- 在XCode中配置openinstall为当前应用生成的关联域名(Associated Domains):applinks:xxxx.openinstall.io
- 集成 Scheme,只适用于iOS9以下
- 在Xcode里选中 Target -> Info -> URL Types,配置 openinstall 为当前应用生成的 Scheme,如图所示
- 参数验证
Objective-C- (void)loginSuccess:(AccessLoginInfo *)success; AccessLoginInfo对象对应的extendInfo字段进行获取。
SDK常见错误解决方式
错误1: dyld: Library not loaded: /System/Library/Frameworks/Network.framework/Network Referenced from: /var/containers/Bundle/Application/BC0FE029-D796-4FF6-A2142C5D0EBA6434/ios-platform-sdk.app/ios-platform-sdkReason: image not found Message from debugger: Terminated due to signal 6
解决方式:将Status -> 设置为Optional
错误2: 当调起苹果登录的时候提示遇到“授权请求失败未知原因”解决如下:
- 请检查是否有添加Sign in with Apple的Capabilities
- 多半是对应的entitlements文件和引用的文件不对应,可以先删除对应的entitlements文件,然后再次添加Capabilities,然后会生成新的entitlements文件。
- 要检查Release下是否也有添加Sign in with Apple的Capabilities