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 的任何文件中,请在文件顶部添加:
PayListModel
已更名为 SohaIAPProductList
。
SohaIAPModel
已更名为 SohaIAPProduct
。
更新方法调用¶
新增¶
1.3.x.x 版本的新功能是注册远程推送通知并为您处理通知中心的委托。
已更新¶
初始化¶
启用跟踪预警屏幕¶
Info
在 1.3.0.1 版本中,SohaGame SDK 将不再自动显示请求跟踪授权的弹出窗口(适用于 iOS 版本 14.5 及以上)。您需要手动请求跟踪授权。SDK 还提供了 requestTracking
方法以呈现 App Tracking Transparency 授权请求。
登出¶
删除账号¶
更改 SDK 语言¶
SohaSetting¶
SohaDelegate 协议¶
- (void)sohaLoginDelegate:(SohaUser *)user{
}
- (void)sohaLogoutDelegate:(SohaUser *)user{
}
- (void)sohaDeleteAccountDelegate:(SohaUser *)user{
}
- (void)sohaDidPurchaseSuccess:(SohaTransaction *)transaction{
}
- (void)sohaDidPurchaseFailed:(SohaTransaction *)transaction purchaseError:(NSString *)error{
}
推送通知¶
注册设备标记
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 的支付中心
记录事件¶
1.3.x.x 版本中的事件记录方法已有很大变化。现在,事件记录方法具有更明确直观的语法。
create_characte 事件:
set_role 事件:
complete_tutorial 事件:
shg_first_purchase 事件:
投票应用事件:
自定义事件:
已删除¶
已删除 SohaDelegate
协议的 sohaLoginDelegate
方法。
已删除 sohaHandleDidBecomeActive
。
已删除 sohaHandleDidEnterBackground
。
已删除 sohaHandleDidEnterForeground
。
已删除 sohaHandleWillTerminate
。