SohaSDK¶
Overview¶
SohaSDK is the main class of the SohaGame iOS SDK, and encapsulates most of the methods.
To import SohaSDK:
#import <SohaSDK/SohaSDK.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, SohaDelegate>
@end
Method¶
startWithDelegate¶
Start the SDK
Declaration
+(void)startWithDelegate:(nonnull id<SohaDelegate>)delegate
application:(nonnull UIApplication *)application
launchOptions:(nonnull NSDictionary *)launchOptions
loginManually:(BOOL)manually;
delegate
The delegate of a SohaDelegate
object must conform to this protocol to receive data from SohaSDK.
application
UIApplication.
launchOptions
A static collection of objects associated with unique keys.
loginManually
To auto-login after starting the SDK, set loginManually to YES. Default is NO.
startWithDelegate¶
Start the SDK with language
Declaration
+(void)startWithDelegate:(nonnull id<SohaDelegate>)delegate
application:(nonnull UIApplication *)application
launchOptions:(nonnull NSDictionary *)launchOptions
loginManually:(BOOL)manually
language:(SohaSDKLanguage)language;
delegate
The delegate of a SohaDelegate
object must conform to this protocol to receive data from SohaSDK.
application
UIApplication.
launchOptions
A static collection of objects associated with unique keys.
loginManually
To auto-login after starting the SDK, set loginManually to YES. Default is NO.
language
Set the language for the SDK.
changeLanguage¶
Set an optional language for the SDK
Declaration
Parameters
language
This is the language code supported by the SDK.
loginWithCallback¶
Starts an interactive login flow on iOS.
The login completion will be called at the end of this process. Note that this method is only called after the SohaSDK has been successfully initialized.
Declaration
Parameters
callback
The SohaLoginCallback
block that is called on completion.
logout¶
Logout the current user,
Declaration
requestPushNotification¶
Requests the user’s authorization to allow local and remote notifications.
Use this method if you want the SDK to register remote notifications for your app. Also when using this method, the SDK will also automatically handle push notifications when the app is running in the foreground.
Declaration
registerDeviceToken¶
Register device token for remote push notification.
Declaration
Parameters
deviceToken
The deviceToken
from application:didRegisterForRemoteNotificationsWithDeviceToken:
.
didReceiveNotificationResponse¶
Determine whether the user opens the app from the push notification.
If you don't use method requestPushNotification
, you need to implement userNotificationCenter:didReceiveNotificationResponse:
method of UNUserNotificationCenterDelegate
protocol and call this method in it.
Declaration
Parameters
response
The response
from userNotificationCenter:didReceiveNotificationResponse:
.
willPresentNotification¶
Handle display of push notifications if app is in foreground.
If you don't use method requestPushNotification
, you need to implement userNotificationCenter: willPresentNotification: withCompletionHandler:
method of UNUserNotificationCenterDelegate
protocol and call this method in it.
Declaration
Parameters
notification
The notification
from userNotificationCenter: willPresentNotification: withCompletionHandler:
.
application:openURL¶
Reports app open from deep link.
Declaration
+(BOOL)application:(nonnull UIApplication *)application openURL:(nonnull NSURL *)url
options:(nonnull NSDictionary *) options;
openSDKPurchase¶
Call this method to open SohaSDK's in-app purchase interface.
When using SohaSDK's in-app purchase interface, purchases will be made automatically when the user taps on the in-app purchases. Results will be returned in delegates sohaDidPurchaseSuccess:
on success or sohaDidPurchaseFailed:purchaseError:
on failure.
Declaration
getListProduct¶
Fetch in-app purchase product information.
Declaration
+(void)getListProduct:(void (^_Nonnull) (NSArray *_Nullable products, NSString * _Nullable error))completionBlock;
Parameters
completionBlock
The block is called on completion, returning an array of in-app purchase items and error codes in case of failure.
payProductShowLoadingWithID:ext¶
Call this method to make an in-app purchase with optional parameter and show loading indicator.
Declaration
Parameters
productID
This is an in-app purchase item identifier. This identifier is obtained from the array of items after calling the function getListProduct:
ext
Your optional parameter to define your in-app purchase item according to your intent.
payProductWithID:ext¶
Call this method to make an in-app purchase with optional parameter.
Declaration
Parameters
productID
This is an in-app purchase item identifier. This identifier is obtained from the array of items after calling the function getListProduct:
.
ext
Your optional parameter to define your in-app purchase item according to your intent.
logSetRoleEventWithRoleName¶
Event logging when user selects character or level up.
Need to call this method every time the character level up.
Declaration
+(void)logSetRoleEventWithRoleName:(NSString*_Nonnull)roleName
roleID:(NSString*_Nonnull)roleID
roleLevel:(NSString*_Nonnull)roleLevel
serverName:(NSString*_Nonnull)serverName
serverID:(NSString*_Nonnull)serverID;
Parameters
roleName
Character's name.
roleID
Character's ID.
roleLevel
Character level
serverName
Server name.
serverID
Server ID.
logCreateCharacterEventWithRoleName¶
Event logging when creating a new character.
This method should only be called once.
Declaration
+(void)logCreateCharacterEventWithRoleName:(NSString*_Nonnull)roleName
roleID:(NSString*_Nonnull)roleID
roleLevel:(NSString*_Nonnull)roleLevel
serverName:(NSString*_Nonnull)serverName
serverID:(NSString*_Nonnull)serverID;
Parameters
roleName
Character's name.
roleID
Character's ID.
roleLevel
Character level
serverName
Server name.
serverID
Server ID.
logGameEventWithEventName¶
Logging your custom events.
Declaration
Parameters
eventName
Event's name.
roleID
Vulue of event.
requestTracking¶
Present App Tracking Transparency authorization request.
Declaration
deleteAccount¶
Delete user account.
Declaration
closePopupView¶
Close SDK View.
Declaration
sdkVersion¶
Get SohaGame SDK version.
Declaration