跳转至

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;
Parameters

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;
Parameters

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

+(void)changeLanguage:(SohaSDKLanguage)language;

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

+(void)loginWithCallback:(nullable SohaLoginCallback)callback;

Parameters

callback
The SohaLoginCallback block that is called on completion.

logout

Logout the current user,


Declaration

+(void)logout;

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

+(void)requestPushNotification;

registerDeviceToken

Register device token for remote push notification.


Declaration

+(void)registerDeviceToken:(nonnull NSData *)deviceToken;

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

+(void)didReceiveNotificationResponse:(nonnull UNNotificationResponse *)response;

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

+(void)willPresentNotification:(nonnull UNNotification *)notification;

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

+(void)openSDKPurchase;

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

+(void)payProductShowLoadingWithID:(NSString* _Nonnull)productID ext:(NSString*_Nonnull) ext;

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

+(void)payProductWithID:(NSString* _Nonnull)productID ext:(NSString*_Nonnull) ext;

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

+(void)logGameEventWithEventName:(NSString*_Nonnull)eventName value:(NSDictionary*_Nullable)value;

Parameters

eventName
Event's name.

roleID
Vulue of event.

requestTracking

Present App Tracking Transparency authorization request.


Declaration

+(void)requestTracking;

deleteAccount

Delete user account.


Declaration

+(void)deleteAccount;

closePopupView

Close SDK View.


Declaration

+(void)closePopupView;

sdkVersion

Get SohaGame SDK version.


Declaration

+ (NSString * _Nonnull)sdkVersion;