SUnit SDK Documentation(Unity) - sunitsdk/SUnitUnityDemo GitHub Wiki
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.
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 |
... |
• minSdkVersion 16 or later
• compileSdkVersion 26 or later
-
Add SDK file
Copy Assets/SHAREitSDK to the target project, (the demo file in this directory is an example of the SDK)
-
Adding third-party dependencies
Copy Assets/Plugins/Android/LitJson.dll to the target project. If this file has already existed , do not copy it.
-
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. Custom Gradle Template steps to open the Custom Gradle Template are as follows:
-
File -> Build Settings ->Switch to Android Platform->Player Settings
-
Player Settings -> Player -> android Tab -> check “Custom Gradle Template”
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 .
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.
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" />
- 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 ***
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" />
- 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"/>
- 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()
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>
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
}
shareitSDK:SHAREitSDK.SHAREitSDK Sample
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”);
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”);
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)
***The unitID mentioned in the parameters below comes fron the "Unit Space ID" among different sdks and can be accessed from with the SHAREit ***
- loadInterstitialAd()
shareitSDK.loadInterstitialAd(string unitId)
- 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
- 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)
- loadRewardedAd()
shareitSDK.loadRewardedAd(string unitId);
- 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
- 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);
- 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
- loadAd() will be called after game starts
shareitSDK.loadInterstitialAd(string unitId);
shareitSDK.loadRewardedAd(string unitId);
- **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);
}
- 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
- hiddenBannerAd()
// hiddenBannerAd could hide the ads and stop auto refresh
shareitSDK.hiddenBannerAd();
Please check more details with https://docs.payermax.com/#/19?page_id=238&si=1
shareitSDK.isLogin();
Return value: true: logged in false:not logged in
shareitSDK.userLogin(string gameSecret, new SHAREitSDK.LoginListener (
(string userId, string username, string avatarUrl) => {
});
Parameter description: gameSecret: (Reference: 2.1 )
shareitSDK.getUserId()
//returns userId if successfully logged in ; otherwise returns null.
shareitSDK.logout();
return value: true:logout successful; false:logout failed
- For security reasons, the payment key must be stored on the server, not the client
- If you do not need to integrate Admob or AppLovin, please comment out the corresponding dependent libraries
- If the code below is embeded in "build.gradle" under SUnit SDK
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'])
- signingConfigs formatting
signingConfigs {
release {
storeFile file('./test.keystore')
storePassword 'test1234'
keyAlias 'test'
keyPassword 'test1234'
}
}
2020-11-25
Upgrade pay sdk
2020-6-4
No special steps are required to upgrade to 1.6.2.1
2020-05-12
- You should request sd card permission in the first Awake (The method contains id initialization function, you must use it)
- Unity:SHAREitSDK.SHAREitSDK.requestStoragePermissions();
- Use the lates mainTemplate.gradle File
2020-04-20
- Update to androidx
- Update Ads source: admob facebook mopub applovin unityAds
- Add admob medaitionn applovin and admob medaition unityAds
Use the latest mainTemplate.gradle File:
- 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"
}
- 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"
2020-03-29
- Fix bugs of reporting
2020-03-20 No special steps are required to upgrade to 1.2.4
2020-03-11
- Update pay module, fix bugs
- Fix Applovin Banner request API
- Optimize Banner ad logic
- Add floating ball function
2020-03-03
No special steps are required to upgrade to 1.2.2
2020-02-17
- Optimize consumer proguard file
2020-02-14
- No special steps are required to upgrade to 1.2.0.4
2020-02-12
- Unified SDK version number
2020-02-11
- SDK use maven
- Fix bugs
2020-01-19
- Optimize isInterstitialAdReady() of Interstitial
- Optimize isRewardedAdReady() of Rewarded
- Optimize showRewardedBadgeView()
2020-02-11
No special steps are required to upgrade to 1.1.1.1.
2020-01-13
No special steps are required to upgrade to 1.1.1.1.
2020-01-08
No special steps are required to upgrade to 1.1.0.1.
2020-01-07
- 2.1 Embedded Advertising Configuration
- 3.2.4 Adding a Default Ad configuration file
- Deleted automatic permission request method in 6.3 and provided permission application method in 3.8
2019-12-31
- 3.5 : modify the initialization
- 4.1: removes the gameStart and gameEnd event reporting
- 6.3: add automatic permission request methods
2019-12-23
- 3.3 SDK Network Dependence of Advertising Sources (Mopub)
- 4.3.4 more details with banner
2019-11-04
- Interface parameter description
- Issues with read and write permissions
2019-10-22
- AppID must be applied
- Login with horizontal screen adaptation
- More detaiks for isAdReady
- More detaiks for showAd
- Fix bug
2019-09-10
- Initial document