To use Gamebase iOS SDK, initialization is required.
First, import Gamebase header file to the app.
Get the following header file to where Gamebase functions will be initialized, such as AppDelegate.h.
#import <Gamebase/Gamebase.h>
When the game starts, enable the Debug Mode and reset the Gamebase to implement the flow as shown below so that entering the game will be determined based on the Launching Status Code.
When Gamebase is initialized, Gamebase setting can be modified with TCGBConfiguration.
API | Mandatory(M) / Optional(O) | Description |
---|---|---|
configurationWithAppID:appVersion: | M | Set App ID and app version of TCGBConfiguration. Status of update or maintenance can be decided upon a game version. Specify a game version. |
enablePopup: | O | [UI] When a game user cannot play games due to system maintenance or banned from use, reasons need to be displayed by pop-ups. If it is set to YES, Gamebase will automatically display information via pop-ups. The default value is NO. When set to NO, get information from launching results and display why user cannot play games by using customized UI. |
enableLaunchingStatusPopup: | O | [UI] Depending on the launching results, when unavailable to login (mainly due to maintenance), you may decide whether to allow Gamebase to automatically display pop-ups. Works only when enablePopup:YES. The default value is YES. |
enableBanPopup: | O | [UI] When a game user is banned, you can change whether to allow Gamebase to automatically display a pop-up on the reasons. Works only when enablePopup:YES. The default value is YES. |
Gamebase shows warning and error logs only. To turn on system logs for the reference of development, call [TCGBGamebase setDebugMode:YES].
[Caution]
Before releasing a game, be sure to delete setDebugMode call from a source code or change the parameter to NO.
You can also perform the debug setting in the console and the values set in the console have priority. Please see the following guide to set in the console.
Process initialization, in application:didFinishLaunchingWithOptions:.
[Caution]
The initializeWithConfiguration:launchOptions:completion: method call can be made from application:didFinishLaunchingWithOptions: , as well.
[Caution]
The initializeWithConfiguration:launchOptions:completion: method must be called before a call is made for another Gamebase API.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *projectID = @"T0aStC1d";
NSString *gameAppVersion = @"1.2";
TCGBConfiguration *configuration = [TCGBConfiguration configurationWithAppID:projectID appVersion:gameAppVersion];
[configuration enablePopup:YES];
[configuration enableLaunchingStatusPopup:YES];
[configuration enableBanPopup:YES];
[TCGBGamebase initializeWithConfiguration:configuration launchOptions:launchOptions completion:^(id launchingData, TCGBError *error) {
if ([TCGBGamebase isSuccessWithError:error] == YES) {
// Gamebase Initialization is Succeeded
}
}];
}
Check launching status by calling Gamebase#initialize.
Need to call launching status after Gamebase is initialized.
- (void)myMethodAfterGamebaseInitialized {
TCGBLaunchingStatus launchingStatus = [TCGBLaunching launchingStatus];
// You can check whether if Gamebase was initialized or not using this launchingStatus
if (launchingStatus == 0) {
NSLog(@"Service is not initialized.");
}
// After Initialize Complete
if (launchingStatus == INSPECTING_SERVICE) {
NSLog(@"Service in Maintenance");
} else if (launchingStatus == IN_SERVICE) {
NSLog(@"Service in Service");
} else {
...
}
}
With the launchingInformations API, you can get the LaunchingInfo object after initialization.
[Caution]
The launchingInformations API is not an asynchronous API that retrieves information from the server in real time. It returns cached information updated every 2 minutes, so it is not suitable for real-time checking of the current status. In that case, use GamebaseEventHandler, which triggers an event when the Launching Status Code is changed. Game > Gamebase > iOS SDK User Guide > ETC > Additional Features > Gamebase Event Handler > Observer
API
#import <Gamebase/Gamebase.h>
NSDictionary* launchingInfo = [TCGBLaunching launchingInformations];
Refers to Gamebase launching data.
1.1 status
The game status information belongs to the app version entered for the setting of Gamebase Android SDK initialization.
Refer to the table for status codes:
Status | Code | Description |
---|---|---|
IN_SERVICE | 200 | Service is now normally provided. |
RECOMMEND_UPDATE | 201 | Update is recommended. |
IN_SERVICE_BY_QA_WHITE_LIST | 202 | Under maintenance now but QA user service is available. |
IN_TEST | 203 | Under test |
IN_REVIEW | 204 | Review in progress |
IN_BETA | 205 | Beta server environment |
REQUIRE_UPDATE | 300 | Update is required. |
BLOCKED_USER | 301 | User whose access has been blocked. |
TERMINATED_SERVICE | 302 | Service has been terminated. |
INSPECTING_SERVICE | 303 | Under maintenance now. |
INSPECTING_ALL_SERVICES | 304 | Under maintenance for the whole service. |
INTERNAL_SERVER_ERROR | 500 | Error of internal server. |
Game > Gamebase > Console Guide > App > App
1.2 app
This is information about apps registered in the Gamebase Console.
Game > Gamebase > Console Guide > App > Client
1.3 maintenance
This is information about maintenance registered in the Gamebase Console.
Game > Gamebase > Console Guide > Operation > Maintenance
If both the enablePopup
and enableLaunchingStatusPopup
values are true
, a maintenance popup will be automatically displayed if the game is in maintenance status.
If you click the DETAILS button here, the maintenance information is automatically displayed in a webview.
If you want to modify the displayed HTML file, download the HTML file from the following link, modify it as you need, and add it as the gamebase-maintenance.html file in Copy Bundle Resources
of the Xcode project.
HTML file download link
1.4 notice
This is information about notification registered in the Gamebase Console.
Game > Gamebase > Console Guide > Operation > Notice
1.5 user
Below is the user information who initialized Gamebase.
The appKey of the NHN Cloud service associated with Gamebase.
This is information about IAP stores registered in the NHN Cloud console.
Game > Gamebase > Console Guide > Purchase
The information users entered in the NHN Cloud Launching Console.
Game > Gamebase > Console Guide > Management > Config
If GameClientVersion that is not registered in the Gamebase Console is initialized, the LAUNCHING_UNREGISTERED_CLIENT(2004) error occurs. In the enablePopup(true), enableLaunchingStatusPopup(true) status, it forces the update popup to be displayed and users can move to the market. If the Gamebase popup is not used, the related UI can be manually implemented so users can move to the market by acquiring UpdateInfo from the TCGBError object.
VO
@interface TCGBUpdateInfo : NSObject
// Store installation URL that can download the latest version.
@property (nonatomic, strong, nullable) NSString* installUrl;
// A message that is exposed to users; it is delivered in the language set by the user's device.
// The message is as below if the language is 'en.'
// 'The version is not supported. Please get the latest update version.'
@property (nonatomic, strong, nullable) NSString* message;
@end
API
+ (nullable TCGBUpdateInfo *)updateInfoFromError:(nonnull TCGBError *)error;
Example
- (void)initializeGamebase {
TCGBConfiguration* config = [TCGBConfiguration configurationWithAppID:@"YOUR_APP_ID" appVersion:@"YOUR_APP_VERSION" zoneType:@"YOUR_ZONE_TYPE"];
[TCGBGamebase initializeWithConfiguration:config completion:^(id launchingData, TCGBError *result) {
if (result == nil) {
// Gamebase initialization succeeded.
} else {
// Gamebase initialization failed.
TCGBUpdateInfo* updateInfo = [TCGBUpdateInfo updateInfoFromError:result];
if (updateInfo) {
// Unregistered game client version.
// Open market url to update application.
NSLog(@"UpdateInfo after initialize => \n%@", [updateInfo prettyJsonString]);
}
}
}];
}
To manage iOS app events, implement the following UIApplicationDelegate protocol.
[Caution]
If you are using SceneDelegate (iOS 13 or later), UISceneDelegate protocol must be implemented.
You need to notify Gamebase that your app has started by calling the application:didFinishLaunchingWithOptions: method.
// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return [TCGBGamebase application:application didFinishLaunchingWithOptions:launchOptions];
}
Call application:openURL:options: method to notify Gamebase when application's external URL was tried to be open. Gamebase will deliver a corresponding value to authentication SDK of each IdP to make it operate as required.
// AppDelegate.m
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [TCGBGamebase application:app openURL:url options:options];
}
If you are using SceneDelegate (iOS 13 or later), scene:openURLContexts: method must be called.
// SceneDelegate.m
- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
[TCGBGamebase scene:scene openURLContexts:URLContexts];
}
Call applicationDidBecomeActive: method to notify Gamebase whether an app has been activated or not. Gamebase delivers a corresponding value to authentication SDK of each IdP to make it operate as required.
// AppDelegate.m
- (void)applicationDidBecomeActive:(UIApplication *)application {
[TCGBGamebase applicationDidBecomeActive:application];
}
If you are using SceneDelegate (iOS 13 or later), sceneDidBecomeActive: method must be called.
// SceneDelegate.m
- (void)sceneDidBecomeActive:(UIScene *)scene {
[TCGBGamebase sceneDidBecomeActive:scene];
}
Call applicationDidEnterBackground, to notify Gamebase that an app will be converted to background.
// AppDelegate.m
- (void)applicationDidEnterBackground:(UIApplication *)application {
[TCGBGamebase applicationDidEnterBackground:application];
}
If you are using SceneDelegate (iOS 13 or later), sceneDidEnterBackground: method must be called.
// SceneDelegate.m
- (void)sceneDidEnterBackground:(UIScene *)scene {
[TCGBGamebase sceneDidEnterBackground:scene];
}
Call applicationWillEnterForeground, to notify Gamebase that an app will be converted to foreground.
// AppDelegate.m
- (void)applicationWillEnterForeground:(UIApplication *)application {
[TCGBGamebase applicationWillEnterForeground:application];
}
If you are using SceneDelegate (iOS 13 or later), sceneWillEnterForeground: method must be called.
// SceneDelegate.m
- (void)sceneWillEnterForeground:(UIScene *)scene {
[TCGBGamebase sceneWillEnterForeground:scene];
}
Error | Error Code | Description |
---|---|---|
TCGB_ERROR_NOT_INITIALIZED | 1 | Gamebase is not initialized. |
TCGB_ERROR_NOT_LOGGED_IN | 2 | Login is required. |
TCGB_ERROR_INVALID_PARAMETER | 3 | Invalid parameter. |
TCGB_ERROR_INVALID_JSON_FORMAT | 4 | Invalid JSON format. |
TCGB_ERROR_USER_PERMISSION | 5 | User is not authorized. |
TCGB_ERROR_NOT_SUPPORTED | 10 | The function is not supported. |
TCGB_ERROR_NOT_SUPPORTED_IOS | 12 | The function is not supported by iOS. |