iOS SDK

Prev Next

Classic/VPC環境で利用できます。

iOSでゲームを開発するための GAMEPOT iOS SDKの使用方法について説明します。SDKをインストールして環境を構成することで、ゲームとダッシュボードを連携できます。

システム要件

iOS用 GAMEPOT SDKを使用するためのシステム要件は、次の通りです。

  • 最低スペック: iOS 15以降
    (以前のバージョンの iOSへの対応が必要な場合は、お問い合わせチャネルにてご確認ください。)

SDKのインストールと環境の構成

iOS SDKをインストールしてから環境を構成し、GAMEPOTのダッシュボードとゲームを連携してゲーム開発に必要な機能を使用できます。

GAMEPOT SDKでサポートしている言語は次の通りです。

  • 韓国語、英語、イタリア語、タイ語、ベトナム語、日本語、中国語(簡体字/繁体字)、インドネシア語、ドイツ語、スペイン語、フランス語

アプリ実行時にデバイスの言語によって SDK内サポート言語で表記され、サポートされていない言語は英語で表記されます。

SDKのインストール

GAMEPOT iOS SDKをインストールしてプロジェクトを設定する方法は次の通りです。

  1. 管理者アカウントでダッシュボードにログインします。
  2. iOSプロジェクトフォルダの CocoaPodsを利用して Podfileを作成します。
    pod init
    
  3. podfileファイルに NBase SDKを追加します。Podfileの定義は以下の「Podfileの設定」項目をご参照ください。
  4. CocoaPodsを利用して NBase SDKをインストールします。
    pod install
    
参考

iOS SDKを正常にインストールするには、cocoapodsがインストールされている必要があります。

Podfileの設定

エディタで Podfileを開き、GAMEPOT SDKに必要なフレームワークを追加します。

platform :ios, '15.0'

# プロジェクトのメインターゲット
target 'プロジェクトのメインターゲット' do
...
  pod 'NBase'
...
end
  • Googleログインと Facebookログインを使用する場合
platform :ios, '15.0'

target 'GAMEPOT_GAME' do
 use_frameworks!

 # Pods for Nbase SDK
 pod 'NBase'
 pod 'NBaseAdapterProviderGoogle'
 pod 'NBaseAdapterProviderFacebook'
end
Name Version Description Dependeny modules
NBase 3.0.59 GAMEPOT基本モジュール X
NBaseAdapterProviderGoogle 3.0.56 Googleログイン X
NBaseAdapterProviderFacebook 3.0.57 Facebookログイン FBSDKLoginKit (17.4.0)
NBaseAdapterProviderNaver 3.0.57 NAVERログイン X
NBaseAdapterProviderLine 3.0.57 LINEログイン X
NBaseAdapterProviderKakao 3.0.56 Kakaoログイン X
NBaseAdapterProviderX 3.0.57 Xログイン X

メール、Apple、ゲストログインの場合は基本モジュールに適用されています。

注意

一部の依存関係にあるフレームワークは Swift Package Managerを通じてのみ追加できます。

  1. Xcodeでプロジェクト設定に移動し、Package Dependencies設定に移動します。
    gamepot-UnitySDK05.png

  2. 右上の url入力欄に「https://github.com/apollographql/apollo-ios.git」を追加して検索し、apollo-iosを選択した後、Add Packageで追加します。

  3. 表示されるモーダル内の Apollo、ApolloAPIモジュールをプロジェクトのメインターゲットに追加します。
    gamepot-UnitySDK06.png

    Name Dependeny modules Location Version Framework
    NBase Apollo https://github.com/apollographql/apollo-ios.git 1.15.2 Apollo, ApolloAPI

事前準備

  1. プロジェクト IDとプロジェクトキーはダッシュボード > プロジェクトの設定でコピーします。
  2. ログイン、ストア、連携の環境設定はダッシュボード > プロジェクトの設定で行えます。
  3. ログイン別にログイン手段別環境設定を参照し、コンソールに設定してダッシュボードに追加します。
  4. In-App決済時はストア別環境設定を参照し、コンソールに設定してダッシュボードに追加します。
  5. In-App決済のために、ストアごとにアイテムを登録します。 ダッシュボード > 決済 > In-App で追加します。

リセット

リセットを実行するには、ゲームを始める際にロードされる最初の画面に使用されるインスタンスに、以下のコードを追加します。

Swift:

import NBase

NBase.initialize([projectId], projectKey: [projectKey], storeId: [storeId], language: [language], region: [region]) { result in
    switch result {
    case .success(let data):
        NBase.showToast(message: data?.encodeToJson() ?? "")
    case .failure(let error):
        NBase.showToast(message: error.errorDescription ?? "")
    }
}

Objective-C:

[NBaseBridge.shared initialize:[projectId] projectKey:[projectKey] storeId:[storeId] language:[language] region:[region] :^(NSDictionary * _Nullable result, NSError * _Nullable error) {
    if (error) {
        NSLog(@"Initialization Error: %@", error.localizedDescription);
    } else {
        NSLog(@"Initialization succeeded with result: %@", result);
    }
}];
  • Parameter
Key Type Description Required
projectId String プロジェクト ID (ダッシュボード → プロジェクトの設定) O
projectKey String プロジェクトキー (ダッシュボード → プロジェクトの設定) O
storeId String ストア名(apple) O
language String 言語(en、ko、jp...) O
region String リージョン名(kr、jp、sg、us、eu、preview) O
  • Callback
Key Type Description
status Bool 状態
language String 言語
country String
remote_ip String IP
platform String プラットフォーム
sandbox Bool サンドボックスかどうか

ログイン機能

ログイン機能を使用する

開発会社で実装したログイン UIにより、ログインボタンをクリックしたときに動作する SDKログイン機能を使用するには、以下のコードを使用します。

Swift:

NBase.signIn(serviceType: .google) { result in
    switch result {
    case .success(let data):
        // signIn Success
        print("signIn Success: \(data)")
        break
    case .failure(let error):
        // signIn failed
        print("signIn Failed: \(error)")
    case .maintenance(let data):
        // maintenance
        /* case 1: Use in-game popup implemented directly by the developer
        case 2: Call the code below to use the SDK's own popup
        NBase.showAppStatusPopup(status: (data?.appStatus)) { status, e in
            // Popup handling
        }
        */
        print("maintenance: \(data)")
    case .update(let data):
        // update
        /* case 1: Use in-game popup implemented directly by the developer
        case 2: Call the code below to use the SDK's own popup
        NBase.showAppStatusPopup(status: (data?.appStatus)) { status, e in
            // Popup handling
        }
        */
        print("update: \(data)")
    }
}

Objective-C:

[NBaseBridge.shared signIn:google :^(NSDictionary * _Nullable result, NSError * _Nullable error, NSDictionary * _Nullable errorData) {
    if (error) {
        // signIn failed
        NSLog(@"signIn Failed: %@", error.localizedDescription);
    } else if (result) {
        NSDictionary *appStatus = result[@"appStatus"];
        if (appStatus && appStatus[@"type"]) {
            NSString *statusType = appStatus[@"type"];
            
            if ([statusType isEqualToString:@"maintenance"]) {
                // maintenance
                /* case 1: Use in-game popup implemented directly by the developer
                case 2: Call the code below to use the SDK's own popup
                [NBaseBridge.shared showAppStatusPopup:appStatus :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                    // Popup handling
                }];
                */
                NSLog(@"maintenance: %@", appStatus);
            }
            else if ([statusType isEqualToString:@"update"]) {
                // update
                /* case 1: Use in-game popup implemented directly by the developer
                case 2: Call the code below to use the SDK's own popup
                [NBaseBridge.shared showAppStatusPopup:appStatus :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                    // Popup handling
                }];
                */
                NSLog(@"update: %@", appStatus);
            }
        }
        else {
            // signIn success
            NSLog(@"signIn Success: %@", result);
        }
    }
}];

アップデート / メンテナンス時に SDKが提供する独自のポップアップを使用する場合、以下のコードを追加します。

Swift:

NBase.showAppStatusPopup(status: appStatus){ status, e in
    if status.close {
        // App Close
    }                                           
    if status.next{
        // Next, Optional update
    }
}

Objective-C:

[NBaseBridge.shared showAppStatusPopup:appStatus :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
    if (popupError) {
        // showAppStatusPopup Error
    } else if (popupResult) {
        BOOL shouldClose = [[popupResult objectForKey:@"close"] boolValue];
        BOOL shouldProceedNext = [[popupResult objectForKey:@"next"] boolValue];
                                    
        if (shouldClose) {
            // App Close
        } else if (shouldProceedNext) {
            // Next, Optional update
        }
    }
}];
  • Parameter
Key Description
SignInServiceType.google Google
SignInServiceType.anonymous ゲスト
SignInServiceType.facebook Facebook
SignInServiceType.apple Apple
SignInServiceType.kakao Kakao
SignInServiceType.x X
SignInServiceType.line LINE
SignInServiceType.naver NAVER
SignInServiceType.github GitHub
SignInServiceType.microsoft Microsoft
SignInServiceType.huawei Huawei
  • User
Key Type Description
id string ユーザーの固有 ID
socialId string ソーシャル ID
name string 氏名 (提供してくれる場合)
email string メール (提供してくれる場合)
token string トークン
age int 年齢 (提供してくれる場合)
profile string プロファイル (提供してくれる場合)
customField string カスタムフィールド
isSignUp bool 会員登録しているかどうか
appStatus AppStatus メンテナンス/アップデート状態
  • AppStatus
Key Type Description
message string メッセージ
startedAt long 開始時間
endedAt long 終了時間
currentAppVersion string 現在のアプリバージョン
updateAppVersion string アップデート後のアプリバージョン
currentAppVersionCode string 現在のアプリバージョンコード
updateAppVersionCode string アップデート後のアプリバージョンコード
isForce bool 強制アップデートかどうか
url string メンテナンス/アップデートが登録された URL

SDK独自提供のログイン UI

GAMEPOT SDKが提供する完成された形のログイン UIを使用できます。
SDKが提供するログイン UIを呼び出すには、以下のコードを使用します。

Swift:

NBase.openSignInUI { result in
    switch result {
    case .success(let data):
        // openSignInUI Success
        print("openSignInUI Success: \(data)")
        break
    case .failure(let error):
        // openSignInUI failed
        print("openSignInUI Failed: \(error)")
    case .maintenance(let data):
        // maintenance
        /* case 1: Use in-game popup implemented directly by the developer
        case 2: Call the code below to use the SDK's own popup
        NBase.showAppStatusPopup(status: (data?.appStatus)) { status, e in
            // Popup handling
        }
        */
        print("maintenance: \(data)")
    case .update(let data):
        // update
        /* case 1: Use in-game popup implemented directly by the developer
        case 2: Call the code below to use the SDK's own popup
        NBase.showAppStatusPopup(status: (data?.appStatus)) { status, e in
            // Popup handling
        }
        */
        print("update: \(data)")
    }
}

Objective-C:

[NBaseBridge.shared openSignInUI:^(NSDictionary * _Nullable result, NSError * _Nullable error, NSDictionary * _Nullable errorData) {
    if (error) {
        // openSignInUI Error
        NSLog(@"openSignInUI Error: %@", error.localizedDescription);
    } else if (result) {
        NSDictionary *appStatus = result[@"appStatus"];
        if (appStatus && appStatus[@"type"]) {
            NSString *statusType = appStatus[@"type"];
            
            if ([statusType isEqualToString:@"maintenance"]) {
                // maintenance
                /* case 1: Use in-game popup implemented directly by the developer
                case 2: Call the code below to use the SDK's own popup
                [NBaseBridge.shared showAppStatusPopup:appStatus :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                    // Popup handling
                }];
                */
                NSLog(@"maintenance: %@", appStatus);
                return;
            }
            else if ([statusType isEqualToString:@"update"]) {
                // update
                /* case 1: Use in-game popup implemented directly by the developer
                case 2: Call the code below to use the SDK's own popup
                [NBaseBridge.shared showAppStatusPopup:appStatus :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                    // Popup handling
                }];
                */
                NSLog(@"update: %@", appStatus);
                return;
            }
        }
        else {
            // openSignInUI Success
            NSLog(@"openSignInUI Success: %@", result);
        }
    }
}];

自動ログイン(オプション)

リセットの後、最後にログインした認証手段で自動ログインを試みます。自動ログインを試行する前に、最終ログイン Providerタイプの確認をお勧めします。

Swift:

// 最終ログイン Providerタイプを確認
let lastProviderType = NBase.getLastProviderType()

if lastProviderType != .none {
    // 最終ログイン情報がある場合にのみ自動ログインを試行
    NBase.signInLastLoggedIn(completionHandler: { result in
        switch result {
        case .success(let data):
            // signInLastLoggedIn Success
            print("signInLastLoggedIn Success: \(data)")
        case .failure(let error):
            // signInLastLoggedIn failed
            print("signInLastLoggedIn Failed: \(error)")
        case .maintenance(let data):
            /* maintenance
            case 1: Use in-game popup implemented directly by the developer
            case 2: Call the code below to use the SDK's own popup
            NBase.showAppStatusPopup(status: (data?.appStatus)) { status, e in
                // Popup handling
            }
            */
            print("maintenance: \(data)")
        case .update(let data):
            /* update
            case 1: Use in-game popup implemented directly by the developer
            case 2: Call the code below to use the SDK's own popup
            NBase.showAppStatusPopup(status: (data?.appStatus)) { status, e in
                // Popup handling
            }
            */
            print("update: \(data)")
        }
    })
} else {
    print("No last login provider found")
}

Objective-C:

// 最終ログイン Providerタイプを確認
SignInServiceType lastProviderType = [NBaseBridge.shared getLastProviderType];

if (lastProviderType != SignInServiceTypeNone) {
    // 最終ログイン情報がある場合にのみ自動ログインを試行
    [NBaseBridge.shared signInLastLoggedIn:^(NSDictionary * _Nullable result, NSError * _Nullable error, NSDictionary * _Nullable errorData) {
        if (error) {
            // signInLastLoggedIn failed
            NSLog(@"signInLastLoggedIn Failed: %@", error.localizedDescription);
        } else if (result) {
            NSDictionary *appStatus = result[@"appStatus"];
            if (appStatus && appStatus[@"type"]) {
                NSString *statusType = appStatus[@"type"];
                
                if ([statusType isEqualToString:@"maintenance"]) {
                    // maintenance
                    /* case 1: Use in-game popup implemented directly by the developer
                    case 2: Call the code below to use the SDK's own popup
                    [NBaseBridge.shared showAppStatusPopup:appStatus :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                        // Popup handling
                    }];
                    */
                    NSLog(@"maintenance: %@", appStatus);
                    return;
                }
                else if ([statusType isEqualToString:@"update"]) {
                    // update
                    /* case 1: Use in-game popup implemented directly by the developer
                    case 2: Call the code below to use the SDK's own popup
                    [NBaseBridge.shared showAppStatusPopup:appStatus :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                        // Popup handling
                    }];
                    */
                    NSLog(@"update: %@", appStatus);
                    return;
                }
            }
            else {
                // signInLastLoggedIn success
                NSLog(@"signInLastLoggedIn Success: %@", result);
            }
        }
    }];
} else {
    NSLog(@"No last login provider found");
}

getLastProviderType() メソッドは、最後にログインした Providerタイプを返します。

signInLastLoggedIn() メソッドは、最後にログインした認証手段で自動ログインを試みます。

  • Callback
Key Type Description
data NBUser ログイン成功時のユーザー情報
error NBaseError ログイン失敗時のエラー情報

ログアウト

SDKログアウト機能を使用するには、以下のコードをお使いください。

Swift:

NBase.signOut() { result in
    switch result {
    case .success(let status):
        // signOut Success
        print("signOut Success: \(status ?? false)")
    case .failure(let error):
        // signOut Failed
        print("signOut Failed: \(error.errorCode), \(error.errorDescription ?? "")")
    }
}

Objective-C:

[NBaseBridge.shared signOut:^(NSNumber *result, NSError *error) {
    if (error) {
        // signOut Failed
        NSLog(@"signOut Failed: %ld, %@", (long)error.code, error.localizedDescription);
    } else {
        // signOut Success
        NSLog(@"signOut Success: %@", result.boolValue ? @"YES" : @"NO");
    }
}];
  • Callback
Key Type Description
status Bool 成功したかどうか

退会

SDK退会機能を使用するには、以下のコードを使用します。

Swift:

NBase.deleteMember() { result in
    switch result {
    case .success(let status):
        // deleteMember Success
        print("deleteMember Success: \(status ?? false)")
    case .failure(let error):
        // deleteMember Failed
        print("deleteMember Failed: \(error.errorCode), \(error.errorDescription ?? "")")
    }
}

Objective-C:

[NBaseBridge.shared deleteMember:^(NSNumber *result, NSError *error) {
    if (error) {
        // deleteMember Failed
        NSLog(@"deleteMember Failed: %ld, %@", (long)error.code, error.localizedDescription);
    } else {
        // deleteMember Success
        NSLog(@"deleteMember Success: %@", result.boolValue ? @"YES" : @"NO");
    }
}];
  • Callback
Key Type Description
status Bool 成功したかどうか

独自の IDとパスワード認証(オプション)

ユーザーがメールアドレスとパスワードを使用してログインできるようにする認証メソッドです。ユーザーのメールアドレスとパスワードに基づいてユーザー認証を行います。この機能は、従来のメール/パスワードベースの認証システムで重要な役割を果たします。

Swift:

NBase.signInWithPassword(username: [username], password: [password], options: [option]) { result in
    switch result {
    case .success(let user):
        NBase.showToast(message: user?.encodeToJson() ?? "")
    case .failure(let error):
        NBase.showToast(message: error.errorDescription ?? "")
    }
}

Objective-C:

[NBaseBridge.shared signInWithPassword:[username] password:[password] options:[options] :^(NSDictionary * _Nullable result, NSError * _Nullable error) {
    if (error) {
        NSLog(@"signInWithPassword Error: %@", error.localizedDescription);
    } else {
        NSLog(@"signInWithPassword succeeded with result: %@", result);
    }
}];

認証情報でログイン(オプション)

外部から取得したソーシャルアカウントの認証情報(Access Token)を使用してログインするには、以下のコードを使用します。

Swift:

NBase.signInWithCredential(providerId: providerId, accessToken: accessToken, options: options) { result in
    switch result {
    case .success(let data):
        // signInWithCredential Success
        print("signInWithCredential Success: \(data)")
    case .failure(let error):
        // signInWithCredential Failed
        print("signInWithCredential Failed: \(error.errorCode), \(error.errorDescription ?? "")")
    case .maintenance(let data):
        /* maintenance
        case 1: Use in-game popup implemented directly by the developer
        case 2: Call the code below to use the SDK's own popup
        NBase.showAppStatusPopup(status: (data?.appStatus)) { status, e in
            // Popup handling
        }
        */
        print("maintenance: \(data)")
    case .update(let data):
        /* update
        case 1: Use in-game popup implemented directly by the developer
        case 2: Call the code below to use the SDK's own popup
        NBase.showAppStatusPopup(status: (data?.appStatus)) { status, e in
            // Popup handling
        }
        */
        print("update: \(data)")
    }
}

Objective-C:

[NBaseBridge.shared signInWithCredential:providerId accessToken:accessToken options:options :^(NSDictionary * _Nullable result, NSError * _Nullable error, NSDictionary * _Nullable errorData) {
    if (error) {
        // signInWithCredential Failed
        NSLog(@"signInWithCredential Failed: %ld, %@", (long)error.code, error.localizedDescription);
    } else if (result) {
        NSDictionary *appStatus = result[@"appStatus"];
        if (appStatus && appStatus[@"type"]) {
            NSString *statusType = appStatus[@"type"];
            
            if ([statusType isEqualToString:@"maintenance"]) {
                /* maintenance
                case 1: Use in-game popup implemented directly by the developer
                case 2: Call the code below to use the SDK's own popup
                [NBaseBridge.shared showAppStatusPopup:appStatus :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                    // Popup handling
                }];
                */
                NSLog(@"maintenance: %@", appStatus);
                return;
            }
            else if ([statusType isEqualToString:@"update"]) {
                /* update
                case 1: Use in-game popup implemented directly by the developer
                case 2: Call the code below to use the SDK's own popup
                [NBaseBridge.shared showAppStatusPopup:appStatus :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                    // Popup handling
                }];
                */
                NSLog(@"update: %@", appStatus);
                return;
            }
        }
        else {
            // signInWithCredential success
            NSLog(@"signInWithCredential Success: %@", result);
        }
    }
}];
  • Parameter
Key Type Description Required
providerId String Provider ID (例: "google"、"facebook"など) O
accessToken String ソーシャルアカウントの Access Token O
options String 追加オプション (任意) X
  • Callback
Key Type Description
data NBUser ログイン成功時のユーザー情報
error NBaseError ログイン失敗時のエラー情報

外部アカウント連携機能

外部アカウント連携機能を使用する

現在の GAMEPOTユーザーアカウントと別のソーシャルアカウントを連携するには、以下のコードを使用します。

Swift:

NBase.createLinking(serviceType: .google) { result in
    switch result {
    case .success(let linkingId):
        // createLinking Success
        print("createLinking Success: \(linkingId ?? "")")
        // アカウント連携成功後の処理ロジック
    case .failure(let error):
        // createLinking Failed
        print("createLinking Failed: \(error.errorCode), \(error.errorDescription ?? "")")
    }
}

Objective-C:

[NBaseBridge.shared createLinking:google :^(NSDictionary * _Nullable result, NSError * _Nullable error) {
    if (error) {
        // createLinking Failed
        NSLog(@"createLinking Failed: %ld, %@", (long)error.code, error.localizedDescription);
    } else {
        // createLinking Success
        NSLog(@"createLinking Success: %@", result);
        // アカウント連携成功後の処理ロジック
    }
}];
  • Parameter
Key Type Description Required
serviceType SignInServiceType 連携対象の Providerタイプ (例: .google、.facebookなど) O
  • Callback
Key Type Description
linkingId String 連携成功時に返される連携 ID

連携リストの確認

現在の GAMEPOTユーザーアカウントと連携されたソーシャルアカウントリストを確認するには、以下のコードを使用します。

Swift:

NBase.getLinkedLists() { result in
    switch result {
    case .success(let linkings):
        // getLinkedLists Success
        print("getLinkedLists Success: \(linkings)")
        // 連携リスト確認後の処理ロジック
    case .failure(let error):
        // getLinkedLists Failed
        print("getLinkedLists Failed: \(error.errorCode), \(error.errorDescription ?? "")")
    }
}

Objective-C:

[NBaseBridge.shared getLinkedLists:^(NSDictionary * _Nullable result, NSError * _Nullable error) {
    if (error) {
        // getLinkedLists Failed
        NSLog(@"getLinkedLists Failed: %ld, %@", (long)error.code, error.localizedDescription);
    } else {
        // getLinkedLists Success
        NSLog(@"getLinkedLists Success: %@", result);
        // 連携リスト確認後の処理ロジック
    }
}];
  • Callback
Key Type Description
linkings Array 連携されたアカウントリスト
  • Linking
Key Type Description
id String 連携 ID (アカウント連携解除時に使用)
username String ソーシャル ID
provider String ソーシャル providerタイプ

連携解除

現在の GAMEPOTユーザーアカウントから特定のソーシャルアカウント連携を解除するには、以下のコードを使用します。

Swift:

NBase.deleteLinking(linkingId: linkingId) { result in
    switch result {
    case .success(let status):
        // deleteLinking Success
        print("deleteLinking Success: \(status ?? false)")
        // 連携解除成功後の処理ロジック
    case .failure(let error):
        // deleteLinking Failed
        print("deleteLinking Failed: \(error.errorCode), \(error.errorDescription ?? "")")
    }
}

Objective-C:

[NBaseBridge.shared deleteLinking:linkingId :^(NSNumber * _Nullable result, NSError * _Nullable error) {
    if (error) {
        // deleteLinking Failed
        NSLog(@"deleteLinking Failed: %ld, %@", (long)error.code, error.localizedDescription);
    } else {
        // deleteLinking Success
        NSLog(@"deleteLinking Success: %@", result.boolValue ? @"YES" : @"NO");
        // 連携解除成功後の処理ロジック
    }
}];
  • Parameter
Key Type Description Required
linkingId String 解除対象の連携 ID (createLinkingまたは getLinkedListsから取得) O
  • Callback
Key Type Description
status Bool 成功したかどうか

アプリ状態の確認

現在のクライアントのメンテナンス / アップデート状態を確認するには、以下のコードを使用します。

Swift:

NBase.checkAppStatus() { status in
    switch status {
        case .success(let data):
        if let data = data {
            switch data {
                case .maintenance(let maintenance):
                    // Maintenance
                    /* case 1: Use in-game popup implemented directly by the developer
                    case 2: Call the code below to use the SDK's own popup
                    NBase.showAppStatusPopup(status: data) { status, e in
                        // Popup handling
                    }
                    */
                case .update(let update):
                    // Update
                    /* case 1: Use in-game popup implemented directly by the developer
                    case 2: Call the code below to use the SDK's own popup
                    NBase.showAppStatusPopup(status: data) { status, e in
                        // Popup handling
                    }
                    */
                }
            } else {
                // AppStatus Success
                print("checkAppStatus success")
            }
        case .failure(let error):
            print("checkAppStatus error: \(error)")
    }
}

Objective-C:

[NBaseBridge.shared checkAppStatus:^(NSDictionary * _Nullable result, NSError * _Nullable error, NSDictionary * _Nullable errorData) {
    if (error) {
        NSLog(@"checkAppStatus error: \(error.localizedDescription)");
    } else if (result) {
        NSString *type = result[@"type"];
        if ([type isEqualToString:@"maintenance"]) {
            // maintenance
            /* case 1: Use in-game popup implemented directly by the developer
            case 2: Call the code below to use the SDK's own popup
            [NBaseBridge.shared showAppStatusPopup:result :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                // Popup handling
            }];
            */
            NSLog(@"maintenance: %@", result);
        }
        else if ([type isEqualToString:@"update"]) {
            // update
            /* case 1: Use in-game popup implemented directly by the developer
            case 2: Call the code below to use the SDK's own popup
            [NBaseBridge.shared showAppStatusPopup:result :^(NSDictionary * _Nullable popupResult, NSError * _Nullable popupError) {
                // Popup handling
            }];
            */
            NSLog(@"update: %@", result);
        }
    } else {
        // AppStatus Success
        NSLog(@"Normal Status - No maintenance or update required");
    }
}];

トラブルシューティング

Q. Authorization failed: Error Domain=AKAuthenticationError Code=-7026
A. TARGETS > +Capability をクリックして Sign in with Appleを追加してください。
gamepot-UnitySDK14.png