SUnit SDK Documentation(Unity) - sunitsdk/SUnitUnityDemo GitHub Wiki

Overview

This document describes the service content of the SUnit Aggregation SDK and the technical integration method.

The SUnit SDK is a package of commercial solutions provided by SHAREit to game partners, including an advertising module, a data acquisition module, a login module, and an online payment service module. It can be used by game partners to integrate into their own applications according to their needs.

  • Advertising Get access to nine mainstream online advertising platforms including AdColony, Admob, AppLovin, Facebook, UnityAd, Vungle, Mopub, Ironsource Fyber with interstitial and rewarded video Ad available.
  • Data collection Collect user behavior data which can be used by game partners to customize the collection and the reporting of events
  • Login Get access to a set of light and compact login feature
  • Online payment Online payment is available among India, Indonesia, the Philippines, and other countries. Payment methods include e-wallets, debit cards, credit cards, online banking, telephone payment, and offline outlets.

Preparation

1 Get the necessary setup info

Our game parnters are able to get the key info below from SHAREit AM

Module ID info for configuration
AD [Required] AppID, UnitID (depending on the selected ad platform)
[Optional] ADMOB_APP_ID (if needed)
[Optional] APPLOVIN_SDK_KEY (If needed)
Game [Required] gameSecret (secret key for login)
Payment [Required] Payment merchant number, payment key
Data reporting [Required] FLURRY_API_KEY
Embedded Ad Configuration [Required] default_layer file

AppID is still required if the ad is not used

2. [AD SDK] Prepare the Excel spreadsheet of the placements scene or inventory to SHAREit AM (in case of monitoring the performance data of each scene of the game and QA testing)

The scene and subPortal in the table will be used in Interstitial and Rewarded Ad
The scenes need to be included in Interstitial Ad
Used interface:isInterstitialAdReady()

The scene and subPortal in the table will be used in Rewarded Ad
Used interface:isRewardedAdReady /showRewardedBadgeView()

The Ad space scene Sample:(scene and subPortal is the real scene in the game)

AD type scene subPortal Ad scenes description
Interstitial itl_game_level_end Interstitial ad pops up at the end of the level
itl_game_level_start Interstitial ad pops up at the start of the level
itl_game_regain_focus Back to the game
...
RewardedAd gameover resurgence relive afer watching the ad
...

SDK calling method

1 SdkVersion Intro

• minSdkVersion 16 or later
• compileSdkVersion 26 or later

2 Import SDK

  1. Add SDK file

    Copy Assets/SHAREitSDK to the target project, (the demo file in this directory is an example of the SDK)

  2. Adding third-party dependencies

    Copy Assets/Plugins/Android/LitJson.dll to the target project. If this file has already existed , do not copy it.

  3. Add default ad profile

    Copy the default_layer[Get the necessary setup info] file to the Assets / StreamingAssets under the target project, and the path is as follows

图片1

3 Configure gradle

1. Custom Gradle Template steps to open the Custom Gradle Template are as follows:

  1. File -> Build Settings ->Switch to Android Platform->Player Settings 图片2

  2. Player Settings -> Player -> android Tab -> check “Custom Gradle Template” 图片3

2. mainTemplate.gradle file Steps to configure Assets/Plugins/Android/mainTemplate.gradle file are as follows: ​ If the file does not exist, copy it directly to this directory; ​ if the file already exists, just Copy the code wrapped between SHAREit start and SHAREit end .

4 Configure AndroidManifest.xml

Replace the "Ad AppId" in 2.1 with "YOUR_APP_ID" in the example below

<manifest>
 <application>
 <meta-data android:name="com.ushareit.ads.KEY_APP_ID"
   android:value="YOUR_APP_ID"/>
 </application>
</manifest> 

**YOUR_APP_ID **is a required parameter. If it is not configured, the Crash prompt will be poped out under test mode while the initialization will fail and ads cannot be obtained in non-test mode.

5 SDK Initialization

Steps to configure Initialization are as followes:

<!-- App channel -->
<meta-data
android:name="com.sunit.channel"
android:value="SHAREit" />

<!--  'debug' is equal to test mode -->
<meta-data
android:name="com.sunit.mode"
android:value="debug" />

<!--  If the application has only one Activity , there is no need to add the string below . If there are multiple activities , the main Activity path will be added into the value part -->
<meta-data
android:name="com.sunit.mainActivity"
android:value="com.unityplayer.UnityActivity" />

<!-- If the application has only one Progress , there is no need to add the string below. If there are multiple processes in the Application, you need to declare the name of the ad-supported processes-->
<meta-data
android:name="com.sunit.adProcess"
android:value="processName" />

6 Ad network SDK dependencies

  • Admob integration Steps to configure the meta-data in the Manifest file are shown below if you need to integrate Admob.
<meta-data
 android:name="com.google.android.gms.ads.APPLICATION_ID"
 android:value="ADMOB_APP_ID" />

***ADMOBAPPID will be provided by the SHAREit ***

7 Flurry data collection dependencies

Steps to configure the meta-data in the Manifest file are shown below if you need to integrate Flurry.

<meta-data
    android:name="flurry.sdk.API_KEY"
    android:value="FLURRY_API_KEY" />

8 SD Card STORAGE permission

  1. We strongly recommend to add WRITE_EXTERNAL_STORAGE permission, and it must be copied as follows. (This permission is conducive to increasing advertising revenue!!!)
<uses-permission      
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="28"
    tools:replace="android:maxSdkVersion"/>
  1. The way to apply the permission mentioned above is as follows and call the first Awake after the application is opened,The method contains id initialization function, you must use it.
SHAREitSDK.SHAREitSDK.requestStoragePermissions()

9. Adapter Android P(API 29)

If your app use the android:targetSdkVersion="29",Please set the value of requestLegacyExternalStorage to true in the AndroidManifest.xml:

  <manifest ... >
      <!-- This attribute is "false" by default on apps targeting
           Android 10 or higher. -->
      <application android:requestLegacyExternalStorage="true" ... >
        ...
      </application>
    </manifest>

10. New in 1.5.1.0 and later versions(Not adding will cause installation package conflicts)

SDK add account_type, content_authority under applicationId in mainTemplate.gradle

defaultConfig { 
    applicationId “com.xx.xx” 
    //SHAREit begin
       multiDexEnabled true
       resValue "string", "account_type", "${applicationId}.type"
       resValue "string", "content_authority","${applicationId}.provider"
    //SHAREit end
}

Interface Parameter Intro

shareitSDK:SHAREitSDK.SHAREitSDK Sample

1 Data reporting

1.1 Data reporting interface for “Game level start”

Data reporting is a must when players go through each "Game level start".

shareitSDK.gameLevelStart(string level)

Data reporting is still required when players fail and begin to replay the level . It is still needed to do so even the game has not set any levels for players but "level" should be replaced by "-1":

shareitSDK.gameLevelStart(“-1”);

1.2 Data reporting interface for “Game level end”

Data reporting is a must when players go through each "Game level end".

shareitSDK.gameLevelEnd(string level);

Data reporting is still required when players tap the "back" button or fail . It is still needed to do so even the game has not set any levels for players but "level" should be replaced by "-1":

shareitSDK.gameLevelEnd(“-1”);

1.3 Common data reporting interface for "onEvent"(Optional)

The interface specific parameters for common data reporting are as follows:

void onEvent(string eventId, Dictionary<string, string> params) 
eventId:Reporting event name (FYI:event name with  "Game level start" and"Game level end" should be excluded)
params:Reporting event parameter
shareitSDK.onEvent(eventId, params)

3 Ad request and impression

***The unitID mentioned in the parameters below comes fron the "Unit Space ID" among different sdks and can be accessed from with the SHAREit ***

3.1 Interstitial Ad

  1. loadInterstitialAd()
shareitSDK.loadInterstitialAd(string unitId)
  1. isInterstitialAdReady()

This mehthod must be called in the main thread

//scene: Ad display scene
shareitSDK.isInterstitialAdReady(string unitId, string scene);

Special scene:If target of using isInterstitialAdReady() repetitively is to access the cache instead of showInterstitialAd(), the scene must use “loop” in order to avoid unneccessary data

shareitSDK.isInterstitialAdReady(unitId,SHAREitSDK.BaseNativeInterface.LOOP);

The scene needs to be passed in for data analysis

  1. showInterstitialAd()

This interface must be called in the main thread

SDK will locate the existing cached object according to the unitId and impression will fail If there is no cached object(Need to be used with isInterstitialAdReady at the same time)

shareitSDK.showInterstitialAd(string unitId, AdShowListener adShowListener)

3.2 Rewarded Ad

  1. loadRewardedAd()
shareitSDK.loadRewardedAd(string unitId);   
  1. isRewardedAdReady()

This interface must be called in the main thread

shareitSDK.isRewardedAdReady(string unitId, string scenePortal);

scenePortal needs to be passed in for data analysis

  1. showRewardedAd()

SDK will locate the existing cached object according to the unitId and impression will fail If there is no cached object(Need to be used with isInterstitialAdReady at the same time)

shareitSDK.showRewardedAd(string unitId, AdShowListener adShowListener);
  1. showRewardedBadgeView() (This method call may be more frequent, please be patient to access)

This interface must be called in the main thread

shareitSDK.showRewardedBadgeView(string scene, string subPortal);
  • Method Purpose: To count the ratio of clickable ad subPortals from display to the click of the portal be helpful for funnel analysis of each rewarded video portal click performance
  • Involved scenes: all rewarded video portal-related scenes
  • Call timing: when The Rewarded button is from being invisible to visible, please reports all visible and clickable subPortal in the current scene

3.3 Best tips for Interstitial Ads and Rewarded Ad Loading Logic

  1. loadAd() will be called after game starts
shareitSDK.loadInterstitialAd(string unitId);
shareitSDK.loadRewardedAd(string unitId);   
  1. **isRewardedAdReady()**should be used first if you want to call showAd() will be called if it returned “true” while the loadAd() will be called if it returned “false”

Interstitial ad code example:

if (shareitSDK.isInterstitialAdReady(unitId,"home")){
    shareitSDK.showInterstitialAd(unitId,null);
} else {
    shareitSDK.loadInterstitialAd(unitId);
}

Rewarded code example:

if (shareitSDK.isRewardedAdReady(unitId,"home","portal1")){
    shareitSDK.showRewardedAd(unitId,null);
} else {
    shareitSDK.loadRewardedAd(unitId);
}

3.4 Banner Ad

  1. showBanner()
// showBanner could enable the request and display of Banner ad and support automatic refresh.
shareitSDK.showBanner(string unitId, int gravity);
// gravity value:
SHAREitSDK.BaseNativeInterface.GRAVITY_TOP
SHAREitSDK.BaseNativeInterface.GRAVITY_BOTTOM
  1. hiddenBannerAd()
// hiddenBannerAd could hide the ads and stop auto refresh
shareitSDK.hiddenBannerAd();

4 Payment module request

Please check more details with https://docs.payermax.com/#/19?page_id=238&si=1

5 Login

1 IsLogin()

shareitSDK.isLogin();

Return value: true: logged in false:not logged in

2 userLogin()

shareitSDK.userLogin(string gameSecret, new SHAREitSDK.LoginListener (
 (string userId, string username, string avatarUrl) => {
});

Parameter description: gameSecret: (Reference: 2.1 )

3 getUserId()

shareitSDK.getUserId()
//returns userId if successfully logged in ; otherwise returns null.

4 Logout()

shareitSDK.logout();

return value: true:logout successful; false:logout failed

Demo sample guide

Unity Demo

Note

  1. For security reasons, the payment key must be stored on the server, not the client
  2. If you do not need to integrate Admob or AppLovin, please comment out the corresponding dependent libraries
  3. If the code below is embeded in "build.gradle" under SUnit SDK
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'])
  1. signingConfigs formatting
signingConfigs {
   release {
       storeFile file('./test.keystore')
       storePassword 'test1234'
       keyAlias 'test'
       keyPassword 'test1234'
   }
}

Change Log

2.3.1.3

2020-11-25

Upgrade pay sdk

1.6.2.1

2020-6-4

No special steps are required to upgrade to 1.6.2.1

1.5.1.3

2020-05-12

  1. You should request sd card permission in the first Awake (The method contains id initialization function, you must use it)
    • Unity:SHAREitSDK.SHAREitSDK.requestStoragePermissions();
  2. Use the lates mainTemplate.gradle File

[Milestone Version]1.3.1.1

2020-04-20

  1. Update to androidx
  2. Update Ads source: admob facebook mopub applovin unityAds
  3. Add admob medaitionn applovin and admob medaition unityAds

Use the latest mainTemplate.gradle File:

  1. Change the Ads source version
    ext {
        VERSION_SUNIT = "1.3.1.1"

        VERSIOVERSION_ADCOLONY_AD="4.1.0"
        VERSION_ADMOB_AD = "18.3.0"
        VERSION_ADMOB_M_FB = "5.6.1.0"
        VERSION_ADMOB_M_MOPUB = "5.10.0.0"
        VERSION_ADMOB_M_UNITYADS = "3.4.2.0"
        VERSION_ADMOB_M_APPLOVIN = "9.11.4.0"

        VERSION_APPLOVIN_AD = "9.11.4"
        VERSION_FACEBOOK_AD = "5.6.1"
        VERSION_FYBER_AD = "7.3.4"
        VERSION_IRONSOURCE_AD = "6.10.2"
        VERSION_UNITY_ADS_AD = "3.4.2"
        VERSION_VUNGLE_AD = "6.4.11"
        VERSION_MOPUB_AD = "5.10.0"
        VERSION_MOPUB_M_ADMOB = "18.3.0.3"
        VERSION_MOPUB_M_FB = "5.6.1.0"

        VERSION_PLAY_SERVICES_LOCATION = "16.0.0"
        VERSION_GSON = "2.8.1"
        VERSION_OKHTTP3 = "3.10.0"
        VERSION_FLURRY = "12.1.0"
    }
  1. Add admob mediation adapter
    implementation "com.google.ads.mediation:facebook:$VERSION_ADMOB_M_FB"
    implementation("com.google.ads.mediation:mopub:$VERSION_ADMOB_M_MOPUB") {
        exclude group: 'com.mopub'
    }
    implementation "com.google.ads.mediation:unity:$VERSION_ADMOB_M_UNITYADS"
    implementation "com.google.ads.mediation:applovin:$VERSION_ADMOB_M_APPLOVIN"
    implementation "com.mopub.mediation:admob:$VERSION_MOPUB_M_ADMOB"
    implementation "com.mopub.mediation:facebookaudiencenetwork:$VERSION_MOPUB_M_FB"

1.2.6.0

2020-03-29

  1. Fix bugs of reporting

1.2.5

2020-03-20 No special steps are required to upgrade to 1.2.4

1.2.4

2020-03-11

  1. Update pay module, fix bugs
  2. Fix Applovin Banner request API
  3. Optimize Banner ad logic
  4. Add floating ball function

1.2.3.6

2020-03-03

No special steps are required to upgrade to 1.2.2

1.2.2

2020-02-17

  1. Optimize consumer proguard file

1.2.1.2

2020-02-14

  1. No special steps are required to upgrade to 1.2.0.4

1.2.0.4

2020-02-12

  1. Unified SDK version number

1.2.0

2020-02-11

  1. SDK use maven
  2. Fix bugs

1.1.2.3

2020-01-19

  1. Optimize isInterstitialAdReady() of Interstitial
  2. Optimize isRewardedAdReady() of Rewarded
  3. Optimize showRewardedBadgeView()

1.1.1.3

2020-02-11

No special steps are required to upgrade to 1.1.1.1.

1.1.1.1

2020-01-13

No special steps are required to upgrade to 1.1.1.1.

1.1.0.1

2020-01-08

No special steps are required to upgrade to 1.1.0.1.

1.0.9.2

2020-01-07

  1. 2.1 Embedded Advertising Configuration
  2. 3.2.4 Adding a Default Ad configuration file
  3. Deleted automatic permission request method in 6.3 and provided permission application method in 3.8

1.0.8.8

2019-12-31

  1. 3.5 : modify the initialization
  2. 4.1: removes the gameStart and gameEnd event reporting
  3. 6.3: add automatic permission request methods

1.0.8.4

2019-12-23

  1. 3.3 SDK Network Dependence of Advertising Sources (Mopub)
  2. 4.3.4 more details with banner

1.0.4.0

2019-11-04

  1. Interface parameter description
  2. Issues with read and write permissions

1.0.1.0

2019-10-22

  1. AppID must be applied
  2. Login with horizontal screen adaptation
  3. More detaiks for isAdReady
  4. More detaiks for showAd
  5. Fix bug

1.0.0.0

2019-09-10

  1. Initial document
⚠️ **GitHub.com Fallback** ⚠️