二、初始化 #
#lfeng/wellplay/客户端集成/IOS
1、密钥配置 #
使用WellplaySDK前应在控制台申请应用的密钥,并在应用程序初始化时设置好。
1.1、自动密钥配置 #
直接在客户端配置WellplaySDK的密钥,由SDK自动完成身份验证等逻辑。
参考代码如下:
#import "AppDelegate.h"
#import "WellplaySDK/WPlay/WPlay.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[WPlay registerWPlayWithAppID:@"your_app_id" appSecret:@"your_app_secret"];
return YES;
}
1.2、手动秘钥配置 #
手动密钥配置适用于有一定开发能力和需求的开发者,允许开发者自行管理APPSecret。
每当有WellplaySDK运行到需要使用APPSecret进行验证的请求时,会通过回调接口返回需要使用APPSecret进行签名的原始字符串SignStr,由开发者根据签名算法自行使用APPSecret对SignStr进行签名,并将签名结果返回,以便WellplaySDK可以继续运行。
这个签名的计算过程可以在开发者自己的服务器上,以实现不需要将
APPSecret存储在客户端的需求。
#import "AppDelegate.h"
#import "WellplaySDK/WPlay/WPlay.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[WPlay registerWithAppID:@"your_app_id" customSignBlock:^WPlaySignModel *(WPlaySignModel *signModel) {
// 待签名的字符串
NSString* strToSign = signModel.signStr;
// 开发者自行完成签名过程(例如交给自己的服务器完成)
signModel.encryptedSign = [YourLib yourSignMethod:strToSign];
// 返回签名请求
return signModel
}];
return YES;
}
签名算法请参考能力综述/客户端签名中的说明。
2、显示配置 #
使用显示配置需要引用WPlayConfigure.h,且应该在社区第一次被展示前设置好。
2.1、设置屏幕方向 #
#import "AppDelegate.h"
#import "WellplaySDK/WPlay/WPlay.h"
#import "WellplaySDK/WPlay/WPlayConfigure.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[WPlay registerWPlayWithAppID:@"your_app_id" appSecret:@"your_app_secret"];
// 是否横屏(默认为竖屏)
[WPlayConfigure sharedWPlayConfigure].isScreenLandscape = NO;
return YES;
}
2.2、是否全屏显示 #
#import "WellplaySDK/WPlay/WPlayConfigure.h"
/**
设置是否全屏展示,默认为NO
*/
[WPlayConfigure sharedWPlayConfigure].isShowWithFullScreen = NO;
2.3、是否隐藏奖励入口 #
#import "WellplaySDK/WPlay/WPlayConfigure.h"
/**
是否隐藏奖励系统,默认为NO
*/
[WPlayConfigure sharedWPlayConfigure].isHidenWPlayReward = NO;
关于
奖励系统的更多信息请参考能力综述/奖励系统中的相关
2.4、是否隐藏反馈入口 #
#import "WellplaySDK/WPlay/WPlayConfigure.h"
/**
是否隐藏工单反馈系统,默认为NO
*/
[WPlayConfigure sharedWPlayConfigure].isHidenWPlayFeedback = NO;