V8 sdk 接入 文檔

環(huán)境

系統(tǒng)環(huán)境 macOS Mojave? 版本10.14.4

開發(fā)環(huán)境 Xcode Version 10.2.1 (10E1001)

一.SDK說明與集成

1.1.獲取參數(shù)

從平臺處,獲取以下參數(shù),用于對接,配置到sdk的Player_Install.plist文件中

1.2.SDK的組成,如下圖所示



?說明:<PlayerFrameWork.framework> 為SDK的靜態(tài)庫和頭文件

?說明:<Player_Install.plist> 為SDK的配置文件

1.3.SDK集成和配置說明

1.將SDK拖入工程主目錄下


1.2.TARGETS->Build Settings->other linker :-ObjC

1.3.工程info.plist添加以下配置

<key>NSAppTransportSecurity</key>


<key>NSAllowsArbitraryLoads</key>


<key>NSPhotoLibraryAddUsageDescription</key>


<key>NSPhotoLibraryUsageDescription</key>

1.4.SDK配置文件Player_Install.plist說明有且只有下面一個參數(shù),這個參數(shù)不清楚可以詢問工作人員


說明:apple_id:蘋果管網(wǎng)注冊的應用id

1.5 切換支付需要添加Player_Install.plist的參數(shù),在應用的info.plist配置一個url schemes參數(shù),用于應用的跳轉

二.SDK接口說明

使用SDK之前,需要#import <PlayerFrameWork/PlayerFrameWork.h>

appdelegate方法,需要在AppDelegate.m加入SDK的這個方法

如若不添加此處函數(shù)實現(xiàn),那么從瀏覽器支付之后回到應用會收不到支付結果

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation

{

? [Player_Api Player_application:application openURL:url sourceApplication:sourceApplication annotation:annotation];

? ? return YES;

}

//iOS10以上使用

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options

{

? ? [Player_Api Player_application:application openURL:url sourceApplication:nil annotation:NO];

? ? return YES;

}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url

{

? ? [Player_Api Player_application:application openURL:url sourceApplication:nil annotation:NO];

? ? return YES;

}

2.1.登錄

只需調用以下代碼即可進入SDK的登入流程,當?shù)侨氤晒Γ琒DK會自動關閉SDK頁面,并且回調用戶信息給游戲

[Player_Api Player_showLoginWithCallBack:^(NSDictionary *responseDic) {

? ? //block激活即是SDK登錄成功,這個時候游戲通過block獲取用戶信息

? ? ? NSString *sdk_userid = responseDic[@"userid"];//sdk的用戶id

? ? ? NSString *sdk_sessionid = responseDic[@"token"];//sdk的sessionid,用于驗證登錄是否成功

? ? ? NSString *uid = responseDic[@"uid"];//客戶的id

? ? ? NSLog(@"userid = %@", sdk_userid);

? ? ? NSLog(@"token = %@", sdk_sessionid);

? ? ? NSLog(@"uid = %@", uid);

? ? ? useridLabel.text = [NSString stringWithFormat:@"userid=%@", sdk_userid];

? ? ? sessionLabel.text = [NSString stringWithFormat:@"token=%@", sdk_sessionid];

}];

//SDK登錄接口,只有在登錄成功的時候才會激活回調,登錄失敗則由sdk處理

+ (void)Player_Api Player_showLoginWithCallBack:(Player_MainBlock)receiverBlock;


2.2.登出

//登出接口,當用戶在游戲菜單登出成功的時候請調用該方法

+ (void)Player_Logout;

//登出回調接口,有兩種情況會激活該block,1.用戶在游戲內進行登出,2.用戶在SDK的菜單進行登出成功,假如是從SDK發(fā)起登出的,請在block激活的時候對游戲進行登出操作

+ (void)Player_LogoutClickWithCallback:(Player_MainBlock)receiverBlock;

登出成功之后應該調出SDK的登錄窗口

2.3. 支付接口

//支付接口

NSDictionary *orderInfo = @{

? ? ? ? ? ? ? ? ? ? ? ? game_cpOrderid: @"testorderid",

? ? ? ? ? ? ? ? ? ? ? ? game_serverID: @"1",

? ? ? ? ? ? ? ? ? ? ? ? game_serverName: @"testserver",

? ? ? ? ? ? ? ? ? ? ? ? game_productID: @"goods002",

? ? ? ? ? ? ? ? ? ? ? ? game_productName: @"商品名字"/*product.localizedTitle*/,

? ? ? ? ? ? ? ? ? ? ? ? game_productdesc: @"goodsdes"/*product.localizedDescription*/,

? ? ? ? ? ? ? ? ? ? ? ? game_ext: @"testattach",

? ? ? ? ? ? ? ? ? ? ? ? game_productPrice: amountTF.text,

? ? ? ? ? ? ? ? ? ? ? ? game_roleID: @"123",

? ? ? ? ? ? ? ? ? ? ? ? game_roleName: @"iOS測試賬號",

? ? ? ? ? ? ? ? ? ? ? ? game_currencyName : @"123",

? ? ? ? ? ? ? ? ? ? ? ? ? ? };

//? ? NSLog(@"支付信息---------%@",orderInfo);

[Player_Api Player_StoreViewWithDict:orderInfo Success:^(NSDictionary *resultDic) {

? ? NSLog(@"支付成功========%@",resultDic);

} failed:^{

? ? NSLog(@"支付失敗---------");

}];



2.4. 設置角色信息接口

該接口在能獲取以下信息的時候再進行設置即可,一般是登錄成功之后。

參數(shù)說明

//設置角色信息

+(void)Player_setRoleInfo:(NSDictionary*)roleInfo;

調用示例

[Player_Api Player_setRoleInfo:@{game_dataType : @"1",

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_serverID : @"s1",

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_serverName : @"testserver",

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_roleID : @"123",

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_roleName : @"iOS測試賬號",

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_roleLevel : @1,

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_roleVip : @3,

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_roleBalence : @12.3,

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_partyName : @"testparty",

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_rolelevelCtime : @"1479196021",

? ? ? ? ? ? ? ? ? ? ? ? ? ? game_rolelevelMtime : @"1479196736",

? ? ? ? ? ? ? ? ? ? ? ? ? ? }];

2.5. 設置是否一鍵登錄

說明:默認為不使用一鍵登錄,如果需要此功能,如下調用

[Player_Api Player_LogoutClickWithCallback:^(NSDictionary *responseDic) {

NSLog(@”登錄成功”);

//block激活即是SDK登錄成功,這個時候游戲通過block獲取用戶信息

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容