Gamota SDK for Unity

Overview

  1. Integrate SDK
  2. Client API

1. Integrate SDK

Download SDK at GMO UnitySDK. The GMOSample are standalone projects that are already set up for you. You can also integrate the SDK for Unity with an existing application. Open GMOUnitySDK6.unitypackage to install SDK to your project.

1.1. Prerequisites

To get started with the GMO Game SDK for Unity, you can set up the SDK and start building a new project, or you can integrate the SDK in an existing project. You can also run the samples to get a sense of how the SDK works.

Required Unity 5.6 or later

1.2. Obtain app api key and client key

  • Retreive all project information from our GM and fill it to 1.3

1.3. Configure your Unity Project

1.3.1. Import plugin

+) Choose menu Assets-> Import Package -> Custom Package -> Change file GMOUnitySDK5.unitypackage

+) Click import to start import GMOUnitySDK6

1.3.2. Configure Unity project

  • Update all the option provided in GMO menu

    • GMO Settings:
      • API Key
      • GMORefcode
      • Package Name
      • Countly App Key
    • Social Settings:
      • Facebook ID
      • Package Display Name
      • Google client ID
      • Google client secret
    • Appflyer:

      • Apple AppID
      • AppsflerKey
    • Adwords:

      • ConversionID
      • Label
      • Value
      • isRepeatable: Don't check

1.4.1. Configure Frameworks (iOS platform only)

To use the SDK for the iOS platform, drag and drop :
GMOSDK.framework
GMOBundle.bundle
AppsFlyerLib.framework
FBSDKCoreKit.framework
FBSDKLoginKit.framework
FBSDKShareKit.framework
FirebaseAnalytics.framework
FirebaseCore.framework
FirebaseCoreDiagnostics.framework
FirebaseInstanceID.framework
FirebaseMessaging.framework
FirebaseNanoPB.framework
GoogleToolboxForMac.framework
nanopb.framework
Protobuf.framework into your Xcode project (which project you build from Unity3D)

Tick on checkbox: “Copy items into destination group's folder (if needed)”.

Config file (Config push notification using Firebase) GoogleService-Info.plist in your Xcode project

1.4.2. Configure Push Notification using Firebase (android platform only)

Config file (Config push notification using Firebase) google-services.xml at folder Plugins/Android/sdk5-complied/res/values.

  • Content example :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="default_web_client_id" translatable="false">{default_web_client_id}</string>
    <string name="firebase_database_url" translatable="false">{firebase_database_url}</string>
    <string name="gcm_defaultSenderId" translatable="false">{gcm_defaultSenderId}</string>
    <string name="google_api_key" translatable="false">{google_api_key}</string>
    <string name="google_app_id" translatable="false">{google_app_id}</string>
    <string name="google_crash_reporting_api_key" translatable="false">{google_crash_reporting_api_key}</string>
    <string name="google_storage_bucket" translatable="false">{google_storage_bucket}</string>
</resources>

2. Client API

2.1 Init and setup SDK

GMO SDK init must be called once when application start via GMOSDKHandler class call GMOSDKHandler.Instance.Init() so most of the time it will be called in your first scene

GMOSDKHandler.Instance.Init();

There are some functions to control SDK flows, have to call them after GMOSDKHandler.Instance.Init()

  • SetKeepLoginSession(BOOL) this function will control the Appota Login Session will be kept or removed at app lauching (when session's removed user has to login again when app start).
    NoteIf this function is not called, login session will be kept by default.
  • SetAutoShowLoginDialog(BOOL) this function will control the Appota Login View will be automatically show at app lauching (when user's not logged in) or you have to call ShowLoginView function to show the LoginView.
    NoteIf this function is not called, login view will automatically show at app lauching (when user's not logged in)

  • SetSDKButtonVisibility(BOOL) call this function to setting hide or show SDK floating button

  • Set Character Important Set role Name function to support payment method, call this after user choose role ID and roleName

GMOSDKHandler.Instance.SetRoleWithRoleName(string roleName, string roleID, string serverName, string serverID)

2.2 User function

2.2.1. Show login view

As mentioned above login dialog flow can be control by function SetAutoShowLoginDialog(BOOL). Automatically show login view at app launching or manual call ShowLoginView when you need:

  • Show Login View
GMOSDKHandler.Instance.ShowLoginView();

GMO Login Dialog contains 5 authorization methods: Facebook, Google, Appota User, Appota Wallet,and Quick Login

Follow this mechanism for login function, please implement OnLoginSuccess callback to authenticate your in-game user.

  • Logout function
GMOSDKHandler.Instance.Logout();
  • Check user login This function will return user logged in state
GMOSDKHandler.Instance.IsUserLogin();
  • Get GMOSession Return GMOSession if logged in
GMOSDKHandler.Instance.GetGMOSession();

2.2.2. Share and send Screenshot to Facebook, Messenger

  • Share Screenshot Facebook if you want share screenshot to facebook
GMOSDKHandler.Instance.ShareScreenFacebook(string imagePath);

    2.2.3.a. Phone number

    • Update phone number user will update phone this screen.
    GMOSDKHandler.Instance.UpdatePhonenumber();
    

    • Get phone number
    GMOSDKHandler.Instance.GetPhonenumber();
    

    2.2.3.c Switch account

    GMOSDKHandler.Instance.SwitchAccount();
    

    2.2.4 Show News View

    GMOSDKHandler.Instance.ShowNewsView();
    

    2.2.5 Show Event View

    GMOSDKHandler.Instance.ShowEventView();
    

    2.2.6 Show Giftcode View

    GMOSDKHandler.Instance.ShowGCView();
    

    2.2.7 Show Rating View

    GMOSDKHandler.Instance.ShowGCView();
    

    2.2.7 Show Support View

    GMOSDKHandler.Instance.ShowSupportView();
    

    2.2.8 Open Fanpage Facebook

    GMOSDKHandler.Instance.OpenFanpage();
    

    2.2.9 Open Group Facebook

    GMOSDKHandler.Instance.OpenGroup();
    

    2.2.4. Handle authenticaiton callbacks

    GMOSDK provide 5 callbacks delegate for login defined in [GMOSDKReceiver], please implement these functions to handle login result


    Login success callback Retreive Appota user info from GMOSession then post to your server to verify and create game user. For more detail about user integration on server: User Integration

    NoteRemember verify Appota UserID, UserName and Access token on your server before procceeding game user integration

    public void  OnLoginSuccess(string GMOSession)
    
    
    Parameter Description
    GMOSession GMOSession is a json string included all user info, convert the string to GMOSession ot easily retrevie user information (GMOSession.AccessToken, GMOSession.UserName,GMOSession.Email,GMOSession.UserID,GMOSession.LoginType)

    Logout callback Callback after user logout with user name, please logout your game account and call showLoginView to login other account

    public void  OnLogoutSuccess(string userName)
    
    

    Close login view callback Callback when user close login view at app launching

    public void  OnCloseLoginView();
    

    Update phone number callback Callback when user update phone success

    public void  OnUpdatePhonenumber(string gmoPhone);
    

    Get phone number callback Callback when user update phone success

    public void  OnGetPhonenumber(string gmoPhone);
    

    Share screenshot facebook/messenger success callback Callback when user share screenshot to facebook/messenger success

    public void  OnShareFacebookSuccess(string GMOSession);
    

    Share screenshot facebook/messenger fail callback Callback when user share screenshot to facebook/messenger fail

    public void  OnShareFacebookFail(string GMOSession);
    

    2.2. Payment function

    Because using GMOSDK payment function you should understand Appota Payment mechanism and configuration. Please study Appota payment mechanism at Appota Payment Document and payment configuration at Appota Developer Portal.

    2.2.1. Show payment view


    You have 2 methods (Google Payment - android platform, Apple Pay - iOS platform) to show payment view. Each payment view represents one or list of payment package. Each package contains information of game coin amount or in-game package.

    Show default list payment view

    You can show payment view with default list payment packages (which is configured on by GM)

    GMOSDKHandler.Instance.ShowPaymentView()
    


    Show payment view for a specific package

    You can show a specific package depends on your in-game mechanism

    GMOSDKHandler.Instance.ShowPaymentViewWithPackageID(string packageID)
    


    Show payment view from SDK floating button User can open Payment, Information view via floating button

    2.2.2 Handle payment callback


    All callbacks in GMOSDKReceiver.

    2.3 Tracking APIs in game

    2.3.1 Download additional update data

    GMOSDKHandler.Instance.TrackUpdateData(bool is_download);
    

    2.3.2 Login game

    GMOSDKHandler.Instance.TrackLoginGame();
    

    2.3.3 React mission

    GMOSDKHandler.Instance.TrackReactMission(String missionName);
    

    2.3.4 Join Clan

    GMOSDKHandler.Instance.TrackJoinClan(String missionName);
    

    2.3.5 Join Battle Clan

    GMOSDKHandler.Instance.TrackJoinBattleClan(String missionName);
    

    2.3.6 First Recharge

    GMOSDKHandler.Instance.TrackFirstRecharge();
    

    2.3.7 Open shop but no recharge

    GMOSDKHandler.Instance.TrackOpenShopButNoRecharge();
    

    2.3.8 TrackOpenShopAndRecharge

    GMOSDKHandler.Instance.TrackOpenShopAndRecharge();
    

    2.3.9 Open welfare

    GMOSDKHandler.Instance.TrackOpenWelfare();
    

    2.3.10 Open Activity

    GMOSDKHandler.Instance.TrackOpenActivity();
    

    2.3.11 TrackLevel

    • Track level of character in game
    GMOSDKHandler.Instance.TrackLevel(int level);