一、准备所需文件
WechatIMG1.jpeg因为ZBGameSDK涉及到Google和Facebook的登录和分享,所以需要将GoogleSignIn.bundle、GoogleSignIn.framework、GoogleSignInDependencies.framework; FBSDKLoginKit.framework、FBSDKShareKit.framework、FBSDKCoreKit.framework、Bolts.framework这些文件一起copy到项目。
其中ZBGameSDK.framework和ZBGameSDK.bundle就是需要用到的动态库和资源文件。
[图片上传中...(无标题.png-83cecf-1533607190549-0)]
二、开始使用
1、将所需的文件拖进自己的项目
无标题.png2、在自己的项目里选择Target -> General -> Embedded Binaries,点击 ‘+’,然后把ZBGameSDK.framework添加进来
无标题.png3、导入SDK的头文件#import <ZBGameSDK/ZBGameSDK.h>
三、登录模块
1、登录、注册、一键登录、找回密码、绑定邮箱都在ZBLoginVC集成了。直接创建ZBLoginVC对象,然后present该vc。
ZBLoginVC *vc = [ZBLoginVC new];
[controller presentViewController:vc animated:NO completion:nil];
ZBLoginVC有如下代理方法
当用账号登录成功时会调用如下代理方法:
- (void)userLoginSuccess:(ZBLoginVC *)loginVC;
当游客登录成功时会调用如下代理方法:
- (void)visitorLoginSuccessful:(ZBLoginVC *)loginVC;
当用第三方登录成功时会调用如下代理方法:
- (void)thirdPartLoginSuccess:(ZBLoginVC *)loginVC;
2、Facebook登录
1)、Facebook登录需要去https://developers.facebook.com/docs/facebook-login/ios创建一个Facebook应用。
2)、创建好了应用之后,请配置 info.plist(不会的话,请看Facebook官方文档)。
3)、配置好info.plist之后,在Appdelegate.m中的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
方法里添加
[[ZBFacebookLoginTool sharedZBFacebookLoginTool]initialFBSDKWtihApplication:application options:launchOptions];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[ZBFacebookLoginTool sharedZBFacebookLoginTool]initialFBSDKWtihApplication:application options:launchOptions];
return YES;
}
4)、在Appdelegate.m中的- (BOOL)application:(UIApplication *)applicationo penURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
方法里添加
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
[[ZBFacebookLoginTool sharedZBFacebookLoginTool] facebookApplication:application openURL:url options:options];
return YES;
}
5)、然后在需要Facebook登录的地方添加如下代码进行登录
[[ZBFacebookLoginTool sharedZBFacebookLoginTool]loginWithController:self success:^(NSString *userID) {
NSLog(@"......userID:%@", userID);
} failure:^(NSError *error){
NSLog(@"......failure");
}];
3、Google登录。
1)、Google登录功能首先需要去https://console.developers.google.com/projectselector/apis/credentials?supportedpurview=project创建一个应用(如果没有Google开发者账号请自行注册)。
2)、创建好了一个应用后,在Xcode中的info里添加Google的URL Scheme
无标题.png3)、在Appdelegate.m中的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法里添加
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Google登录
[[ZBGoogleLoginTool sharedZBGoogleLoginTool] registerGoogleClientID:@"680967176958-gscakqo5juif6226rfft5u3jgjmq109q.apps.googleusercontent.com"];
return YES;
}
4)、在Appdelegate.m中的- (BOOL)application:(UIApplication *)applicationo penURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options方法里添加
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
[[ZBGoogleLoginTool sharedZBGoogleLoginTool] hanleOpenURL:url options:options];
return YES;
}
5)、然后在需要Google登录的地方添加如下代码进行登录
[[ZBGoogleLoginTool sharedZBGoogleLoginTool]loginWithController:self Success:^(NSString *userID) {
NSLog(@"......suerid:%@", userID);
} failure:^(NSError *error){
NSLog(@"......error:");
}];
4、Line登录
1)、先去Line开发者中心注册一个应用https://developers.line.me/console/。
2)、在- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
方法中添加hanleOpenURL
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
//
[[ZBLineManager sharedZBLineManager] handleOpenURL:url];
return YES;
}
/**
Line登录
*/
- (void)lineLogin {
[[ZBLineManager sharedZBLineManager]loginWithSuccess:^(ZBLineUser *user) {
NSLog(@"......userNmae:%@", user.displayName);
NSLog(@"......userID:%@", user.userID);
NSLog(@"......userPicture:%@", user.pictureURLStr);
} failure:^(NSError *error) {
NSLog(@"......error:%@", error);
}];
}
四、锚点
1、安装锚点
[ZBGameAnchor installAnchorSuccess:^(ZBModel *model) {
NSLog(@"......:%@", model.msg);
} failure:^(NSError *error) {
NSLog(@"......error:%@", error);
}];
2、激活锚点
[ZBGameAnchor activationAchorSuccess:^(ZBModel *model) {
NSLog(@"......:%@", model.msg);
} failure:^(NSError *error) {
NSLog(@"......error:%@", error);
}];
3、创角锚点
[ZBGameAnchor createRoleAnchorSuccess:^(ZBModel *model) {
NSLog(@"......:%@", model.msg);
} failure:^(NSError *error) {
NSLog(@"......error:%@", error);
}];
4、Facebook事件记录。自行到Facebook开发者中心https://developers.facebook.com去创建自己的应用。
ZBFacebookManager
这个类是用来做Facebook事件记录
// 激活事件
/**
ActivatedApp Event
*/
+ (void)activatedAppEvent; // 激活
// 注册事件
/**
CompletedRegistration Event
@param registrationMethod registrationMethod
*/
+(void)completedRegistrationEvent :(NSString*)registrationMethod;
// 实现关卡事件
/**
AchievedLevel Event
@param level level
*/
+ (void)achievedLevelEvent:(NSString*)level;
// 支付记录事件(用来记录有支付这个动作)
+ (void)purchasedEvent:(int)numItems
contentType:(NSString*)contentType
contentId:(NSString*)contentId
currency:(NSString*)currency
valToSum:(double)price;
// 支付结果事件(用来记录支付结果)
+ (void)pymentInfo:(BOOL)success;
5、Adjust事件记录,去https://www.adjust.com中自行注册自己的应用
ZBAdvertisingManager这个类实现Adjust的事件记录
// Application的didlaunch方法中初始化Adjust
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Adjust
[ZBAdvertisingManager registerAdjustWhenAppDidLaunch:application adjustToken:@"iiyrnfdbxf5s" adjEnvironment:ZBAdjustEveironmentSanbox];
return YES;
}
// 记录事件方法
+ (void)eventWithEventToken:(NSString *)token;
五、支付,目前有两大类支付:一是APP内购;另外是第三方支付。这两种都集成在
ZBPaySelectManager里。
使用时只需掉用
+ (void)showPayAlertWithVC:(UIViewController *)vc
productID:(NSString *)productID
gameParam:(NSString *)gameParam
cpProductID:(NSString *)cpProductID
cpOrderID:(NSString *)cpOrderID
success:(void(^)(NSInteger diamonds, BOOL isInAppPurchase))success
failure:(void(^)(NSError *error))failure;
在回调的block里处理相应的支付结果。
六、广告
1、Admob广告,首先要自行去https://apps.admob.com中心创建自己的应用。由ZBAdmobManager
类实现该功能
1)、首先要初始化、加载广告
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Admob
// 初始化
[[ZBAdmobManager sharedZBAdmobManager] configureWithAppID:@"ca-app-pub-3940256099942544~1458002511"];
// 加载广告
[[ZBAdmobManager sharedZBAdmobManager] loadRequestWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];
return YES;
}
2)、展示广告
- (IBAction)presentAD {
[[ZBAdmobManager sharedZBAdmobManager] presentADVideoFromViewController:self];
}
2、Unity广告,首先自行创建自己的unity应用https://developer.cloud.unity3d.com。unity广告由ZBUnityManager
该类来实现。
1)、初始化,在使用该广告之前先初始化
[[ZBUnityManager sharedZBUnityManager] initializeWithGameID:@"26***74"];
2)、展示广告
[[ZBUnityManager sharedZBUnityManager] showUnityWithPlacementId:@"Your PlacementId" controller:self];
七、分享
1、 分享URL,Google和Facebook分享
[ZBShareTool shareLink:@"http://baidu.com" controller:self];
2、 图片分享,只有Facebook可分享
UIImage *image = [UIImage imageNamed:@"agree"];
[ZBShareTool shareImage:image controller:self];
八、选择游戏服和角色
1、选择游戏服用ZBSelectGameServerManager
这个类
- (void)selectGameServerManagerWithGameServerID:(nonnull NSString *)gameServerID
gameServerName:(nonnull NSString *)gameServerName
success:(void(^)(void))success
failure:(void(^)(NSString *errorString))failure;
ZBSelectGameServerManager *server = [ZBSelectGameServerManager sharedZBSelectGameServerManager;
[server selectGameServerManagerWithGameServerID:@"123" gameServerName:@"游戏服" success:^{
NSLog(@"成功");
} failure:^(NSString *errorString) {
NSLog(@"失败:%@", errorString);
}];
2、选择角色用ZBSelectRoleManager
这个类
ZBSelectRoleManager *roleManager = [ZBSelectRoleManager sharedZBSelectRoleManager];
[roleManager selectRoleWithRoleName:@"角色名" success:^{
NSLog(@"角色成功");
} failure:^(NSString *errorString) {
NSLog(@"角色失败:%@", errorString);
}];
网友评论