跳转至

SohaSDK for iOS 1.3.x.x 迁移指南

本指南旨在帮助现有应用平稳过渡到使用 SohaSDK 1.2.x.x 到最新 API 的应用,同时解释新功能和更新功能的设计和结构。

要求

  • iOS 13.0
  • Xcode 15.3

升级的好处

  • 代码量减少:减少了多达 30% 的编写代码。
  • 文件大小减小:二进制文件大小现在更小。
  • 直观:API 直观易用 - 易于发现和使用。
  • 加速开发

命名空间变更

您会注意到以前使用的 Soha 不再存在。在您使用 SohaGame iOS SDK 的任何文件中,请在文件顶部添加:

#import <SohaSDK/SohaSDK.h>
PayListModel 已更名为 SohaIAPProductList

SohaIAPModel 已更名为 SohaIAPProduct

更新方法调用

新增

1.3.x.x 版本的新功能是注册远程推送通知并为您处理通知中心的委托。

[SohaSDK requestPushNotification];

已更新

初始化

[Soha sohaInitWithGameDelegate:self
            application:[UIApplication sharedApplication]
            launchOptions:launchOptions
            loginManually:YES
            andSetLanguageTo:SohaSDKLanguageVietnam];
[SohaSDK startWithDelegate:self
        application:[UIApplication sharedApplication]
        launchOptions:launchOptions
        loginManually:YES
        language:SohaSDKLanguageVietnamese];

启用跟踪预警屏幕

[Soha showInAppPopupTracking];
[SohaSDK enableTrackingPreAlertScreen];
[SohaSDK requestTracking];

Info

在 1.3.0.1 版本中,SohaGame SDK 将不再自动显示请求跟踪授权的弹出窗口(适用于 iOS 版本 14.5 及以上)。您需要手动请求跟踪授权。SDK 还提供了 requestTracking 方法以呈现 App Tracking Transparency 授权请求。

登出

[Soha sohaLogoutSDK];
[SohaSDK logout];

删除账号

[Soha deleteAccount];
[SohaSDK deleteAccount];

更改 SDK 语言

[Soha languagueHasChangedTo:SohaSDKLanguageEnglish];
[SohaSDK changeLanguage:SohaSDKLanguageEnglish];

SohaSetting

[SohaSetting sohaSettings];
[SohaSetting settings];

SohaDelegate 协议

- (void)sohaLoginDelegate:(SohaUser *)user{
}

- (void)sohaLogoutDelegate:(SohaUser *)user{
}

- (void)sohaDeleteAccountDelegate:(SohaUser *)user{
}

- (void)sohaDidPurchaseSuccess:(SohaTransaction *)transaction{
}

- (void)sohaDidPurchaseFailed:(SohaTransaction *)transaction purchaseError:(NSString *)error{
}
- (void)sohaDidLogoutSuccess:(SohaUser *)user{
}

- (void)sohaDidDeleteAccountSuccess:(SohaUser *)user{
}

- (void)sohaDidPurchaseSuccess:(SohaTransaction *)transaction{
}

- (void)sohaDidPurchaseFailed:(SohaTransaction *)transaction purchaseError:(NSString *)error{
}

推送通知

注册设备标记

[Soha sohaPostDeviceToken:deviceToken];
[SohaSDK registerDeviceToken:deviceToken];

UNUserNotificationCenterDelegate

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler{
     [Soha userNotificationCenter:center didReceiveNotificationResponse:response];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{
     [Soha userNotificationCenter:center willPresentNotification:notification];
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler{
     [SohaSDK didReceiveNotificationResponse:response];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{
     [SohaSDK willPresentNotification:notification];
}

内购

打开 SDK 的支付中心

[Soha sohaInAppPhurchase];
[SohaSDK openSDKPurchase];

记录事件

1.3.x.x 版本中的事件记录方法已有很大变化。现在,事件记录方法具有更明确直观的语法。

create_characte 事件:

[Soha sendEventCreateCharacter];
[SohaSDK logCreateCharacterEventWithRoleName:role_name
                                      roleID:role_id
                                   roleLevel:role_level
                                  serverName:server_name
                                    serverID:server_id];

set_role 事件:

[Soha sendEventSetRoleName:role_name
                    roleID:role_id
                 roleLevel:role_level
                serverName:server_name
                  serverID:server_id];
[SohaSDK logSetRoleEventWithRoleName:role_name
                              roleID:role_id
                           roleLevel:role_level
                          serverName:server_name
                            serverID:server_id];

complete_tutorial 事件:

[Soha gameDidCompleteTutorial];
[SohaSDK logCompleteTutorialEvent];

shg_first_purchase 事件:

[Soha sendGameEventWithName:@"shg_first_purchase" value:nil];
[SohaSDK logGameEventWithEventName:@"shg_first_purchase" value:nil];

投票应用事件:

[Soha sendEventWithName:SohaSDKEvent];
[SohaSDK logVoteEvent:SohaSDKVoteEvent];

自定义事件:

[Soha sendGameEventWithName:@"<your_event_name>" value:eventData];
[SohaSDK logGameEventWithEventName:@"<your_event_name>" value:eventData];

已删除

已删除 SohaDelegate 协议的 sohaLoginDelegate 方法。

已删除 sohaHandleDidBecomeActive

已删除 sohaHandleDidEnterBackground

已删除 sohaHandleDidEnterForeground

已删除 sohaHandleWillTerminate