iOS SDK

Prev Next

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

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

システム要件

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

  • 最低動作環境: iOS 15.1以降
    (旧バージョンの iOSへの対応が必要な場合は、お問い合わせチャネルまでご連絡ください )

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

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

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

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

GAMEPOT初期化時に登録した言語で自動表示されます。未対応の言語の場合は英語で表示されます。

SDKのインストール

GAMEPOT iOS SDKを導入してプロジェクトを設定する手順は次の通りです。

  1. iOSプロジェクトフォルダの CocoaPodsを利用して Podfileを作成します。
    Terminal:
    pod init
    
  2. podfileファイルに NBase SDKを追加します。Podfileの定義内容は、下記のPodfileの設定項目をご参照ください。
  3. CocoaPodsを利用して NBase SDKをインストールします。
    Terminal:
    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

サポートされている iOS依存モジュールは次の通りです。

Name Description Dependeny modules
NBase GAMEPOT基本モジュール X
NBaseAdapterProviderGoogle Googleログイン X
NBaseAdapterProviderFacebook Facebookログイン FBSDKLoginKit (17.4.0)
NBaseAdapterProviderNaver NAVERログイン X
NBaseAdapterProviderLine LINEログイン X
NBaseAdapterProviderKakao Kakaoログイン X
NBaseAdapterProviderX Xログイン X

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

注意

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

以下は、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モジュールをプロジェクトのメインターゲット(Unity-iPhone)に追加します。
    gamepot-UnitySDK06.png

    以下の表は、Swift Package Managerで追加する依存モジュールを説明します。

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

事前準備

SDKを適用する前に、必須設定項目を次のようにご確認ください。

  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);
    }
}];
  • Parameters

次の表は、初期化に必要なパラメータを説明します。

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
        }
    }
}];
  • Provider

次の表は、ログイン機能で使用するサービスタイプを説明します。

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

次の表は、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

次の表は、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 ログイン失敗時のエラー情報

ログアウト

GAMEPOTユーザーアカウントからログアウトするには、以下のコードを使用してください。

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ユーザーアカウントに外部ソーシャルアカウントを連携して管理する機能を説明します。

外部アカウント連携機能の使用

現在の 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

次の表は、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