Cocos creator asset package**:**
hippo-ad-sdk-cn-1.0.5.zip

iOS ad SDK :
hippo-sdk-frameworks-1.3.0.zip

Android ad SDK:
hippo_ad_sdk_cn.aar-v1.1.4.zip

Update log**:**

Creator Ver. iOS Ver. Android Ver. Developer Date Description
v1.0.0 v1.2.0 v1.0.8 junewong 2019-05-29 Support iOS platform;

provide reward video ads and banner ads APIs | | v1.0.1 | v1.2.1 | v1.0.8 | junewong | 2019-05-29 | Support Android platform with 4 ad | | v1.0.2 | v1.2.2 | v1.0.9 | junewong | 2019-05-30 | 1.iOS platform supports click callback;
2.iOS;platform supports loading and showing error callback
3.Interface method for showVideoAd is changed into showRewardVideoAd
4.Minor bug fixes | | v1.0.2 | v1.2.3 | v1.0.9 | junewong | 2019-06-06 | 1. Alter and add some event tracker | | v1.0.2 | v1.2.4 | v1.0.9 | junewong | 2019-06-06 | 1.Update third-party ad SDK from 1.9.9.2 to 2.0.1.1 | | v1.0.3 | v1.2.5 | v1.0.9 | junewong | 2019-06-11 | 1.Optimize isLoaded method and add test examples | | v1.0.3 | v1.2.5 | v1.1.0 | heyouying | 2019-06-12 | 1.Add Xiaomi Ad(Banner.RewardVideo)
2.Add the method of delivering ad configuration from server end | | v1.0.3 | v1.2.5 | v1.1.1 | heyouying | 2019-06-13 | 1.Add the feature of flexibly conglomerate different third-party ad plarorms | | v1.0.3 | v1.2.5 | v1.1.2 | heyouying | 2019-06-13 | 1.Fix Banner adaptivity bugs | | v1.0.3 | v1.2.5 | v1.1.3 | heyouying | 2019-06-27 | 1.Add configuration for deep analysis channels | | v1.0.4 | v1.2.9 | v1.1.3 | junewong | 2019-07-04 | 1.Upgrade iOS third-party SDK to 2.1.0.1;
2.Open iOS APIs for interstitial and full-screen ads;
3.Add click-to close feature to iOS banner adds; | | v1.0.5 | v1.2.9.1 | v1.1.3 | junewong | 2019-07-11 | 1. Modify the callback mode to be compatible with the 1.x and 2.x versions of Creator; | | v1.0.5 | v1.3.0 | v1.1.3 | junewong | 2019-07-18 | 1.Upgrade third-party SDK to 2.1.0.2 | | v1.0.5 | v1.3.0 | v1.1.4 | heyouying | 2019-07-19 | 1.Upgrade third-party SDK to 2.1.0.2 |

I. Description

This SDK is applied to accessing the advertisement monetizing platform in China, and ensures high efficiency and low maintenance cost with simple procedures to use the advertisement platform and its integrated analysis tools.

This documentation describes the procedures to integrate SDK on Cocos Creator platform, supporting exporting iOS and Android Projects.

II. Preparation

  1. Download Cocos creator asset package and native project package:

  2. Acquire the following configuration file from Hippo operational staff:

  • hippo-ads-config.json It contains information including those related to advertisement. Please do not modify it.
  • ID for every conglomerated ad place.
  1. Supplied material before CP release:
  • If data event tracker is used, please provide Umeng custom event list for import.

III. Procedures

Accessing Cocos creator project

  1. Open Cocos Creator project, go to File – Import Asset and choose the downloaded ASK asset package in to Zip File Directory:

image.png

HippoSDKDemo.fire and HippoSDKDemo.js are demo files,you can choose not to import them if not needed.

Access iOS project

  1. Decompress hippo-sdk-frameworks-xxx.zip in Cocos Creator and import all Frameworks.

  2. Import SDK configuration file

Import hippo-ads-config.json to the root directory of the Project (do not modify the name of .json file):

hippo-ads-config.json

  1. iOS project runtime environment configuration

Supported environment:

  • System version: iOS 8.X or later;
  • SDK compilation environment Xcode 9.4, Base SDK 11.1;
  • Supported architecture: i386, x86-64, armv7, armv7s, arm64 ( above arm64 for real machine)

Please check the following project configuration:

a)Network permission configuration

All existing SDK APIs support HTTPS, but sometimes the main ad element doesn’t. To solve this:

Go to project plist setting, click the ‘+’ next to Information Property List on the right to expand, add information Property List, click arrow on the left to expand, add ‘+’ on the right, auto-fill Allow Arbitrary Loads, and modify its value to YES.
bu_2.png

b)Check whether the following libraries exists, add if not:

Project should find Link Binary With Libraries in Allow Arbitrary Loads. Click ‘+’ and add the dependent libraries missing from the following list:

  • StoreKit.framework
  • MobileCoreServices.framework
  • WebKit.framework
  • MediaPlayer.framework
  • CoreMedia.framework
  • AVFoundation.framework
  • CoreLocation.framework
  • CoreTelephony.framework
  • SystemConfiguration.framework
  • AdSupport.framework
  • CoreMotion.framework
  • libresolv.9.tbd
  • libc++.tbd
  • libz.tbd

c)Add parameter to ‘Other Linker Flags’:

Add parameter -ObjC to Build Settings – Other Linker Flags. SDK supports -all_load at the same time.

bu_3.png

Access Android project

  1. This SDK can run on Android4.1 (API Level 16) or later. If AndroidManifest.xml merging conflict occurs, please modify the minimum version to 16.

  2. Import the aar file extracted from hippo_ad_sdk_cn.aar-xxx.zip to Android project and config its dependency as the following:

1.png

2.png

3.png

  1. // 今日头条轻游
  2. implementation(name: 'applog-release', ext: 'aar') // Deep SDK
  3. implementation(name: 'open_ad_sdk', ext: 'aar') // Ad SDK
  4. implementation(name: 'android-gif-drawable-1.2.6', ext: 'aar')
  5. implementation(name: 'aweme-open-sdk', ext: 'aar') // Share-to-TikTok SDK
  6. implementation(name: 'GameSdk-v102', ext: 'aar') // Jiont Operation SDK
  7. implementation 'com.android.support:support-v4:xx.x.x'//Choose according to the SDK Version used
  8. implementation(name: 'hippo-ad-sdk-v1.0.8', ext: 'aar') // Ad SDK
  1. Import hippo-ads-config.json to the src/main/assets directory of the project (do not modify the name of json file; create the folder if not exist; this directory is under project mode):

src/main/assets/hippo-ads-config.json

  1. Copy src/org/cocos2dx/javascript/HippoAdManager.java extracted from hippo_ad_sdk_cn.aar-xxx.zip to src/org/cocos2dx/javascript of the project;

  2. Android SDK needs to call setContext method on the onCreate method of AppActivity on Android end, as follows:

  1. public class AppActivity extends Cocos2dxActivity {
  2. @Override
  3. protected void onCreate(Bundle savedInstanceState) {
  4. super.onCreate(savedInstanceState);
  5. ......
  6. // Set the necessary context for initializing SDK
  7. HippoAdManager.setContext(this);
  8. }
  9. @Override
  10. public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  11. super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  12. ...
  13. //Initializing Umeng need permission to acquire IMEI
  14. if (requestCode == HippoAdManager.READ_PHONE_STATE) {
  15. HippoAdManager.initHippoSDK();
  16. }
  17. ...
  18. }
  19. }
  1. To properly use statistics function, our API should be called in the life cycle method of every Activity. Call HippoAdManager.onAppResume(activity) in onResume() of Activity, and call HippoAdManager.onAppPause(activity) in onPause() of Activity. ```java public class AppActivity extends Cocos2dxActivity { ………… @Override protected void onResume() {
    1. super.onResume();
    2. HippoAdManager.onAppResume(this);
    }

@Override protected void onPause() { super.onPause(); HippoAdManager.onAppPause(this); } ………… }


7. Obfuscation
```java
# hippo-sdk
-keep class com.hippo.ads.**{*;}
-keep class com.hippo.ads.**
-dontwarn com.hippo.ads.**
-keeppackagenames com.hippo.ads.**

# jrtt-sdk
-keep class com.bytedance.sdk.openadsdk.** { *; }
-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}
-keep class com.androidquery.** {*;}
-keep class com.androidquery.**
-dontwarn com.androidquery.**
-keeppackagenames com.androidquery.**
-keep class com.ss.android.**{*;}
-keep class com.ss.android.**
-dontwarn com.ss.android.**
-keeppackagenames com.ss.android.**

# umeng-sdk
-keep class com.umeng.commonsdk.**{*;}
-keep class com.umeng.commonsdk.**
-dontwarn com.umeng.commonsdk.**
-keeppackagenames com.umeng.commonsdk.**

IV. Instructions of using SDK

1. Initialize SDK

Initialize SDK at the beginning of the game. SDK will automatically search json configuration file and execute initialization.Please keep an eye on the notification of initialization succeeds or fails.

// Turn on log mode during test, please turn off when goes live
HippoAdSDK.logMode();

// Initialize SDK
HippoAdSDK.init( ( success ) => {
    // If success is true, initialization succeeds ands ad can be loaded;
    console.log("hippo_sdk", "SDK init, success:" + success );
});

2. Reward video ads

a) Ads request

Use conglomerated ads place ID and request corresponding ad type.
Please be aware that request once is enough. Later every time an ad is shown or loaded with error, it will automatically request next ad to be loaded.

// Ad place enabling reward video ad
// Parameters:
//    ids:Ad place id array,one or more ids can be transferred into
//    callback: hippoPlacementId:Hippo ad placement id, success:whether successfully loaded
HippoAdSDK.initRewardedVideoAd([HIPPO_AD_REWARD_ID], ( hippoPlacementId, success ) => {
    console.log("hippo_sdk"," reward id:" + hippoPlacementId + " loaded, success:" + success );
});

b)Show Ads

Show reward video ads. Call when triggering ads is needed:

// Show a reward video ad
// Show completion callback parameter:
//    success:whether succeeded
//    errorMessage:failure message when error occurs
//    isRewarded:whether reward is issued
HippoAdSDK.showRewardVideoAd( HIPPO_AD_REWARD_ID, ( success, errorMessage, isRewarded ) => { // Show later callback
    if ( success && isRewarded ) {
        // Show success and issue reward
    }
} , () => { // Click callback
        console.log("hippo_sdk", "reward video clicked." );
});

3. Full-screen video ads

a) Ad request

The form of full-screen video is the same as that of reward video except that user can skip.

// Ad place enabling full-screen video ad
// Parameters:
//    ids:为Ad place id array,one or more ids can be transferred into
//    callback: hippoPlacementId:Hippo ad placement id, success:whether successfully loaded
HippoAdSDK.initFullScreenVideoAd([HIPPO_AD_FULLSCREEN_ID], ( hippoPlacementId, success ) => {
    console.log("hippo_sdk"," fullscreen id:" + hippoPlacementId + " loaded, success:" + success );
});

b)Show Ads

Show reward video ads. Call when triggering ads is needed.

// Show a full-creen video ad
// Show completion callback parameter:
//    success:whether succeeded
//    errorMessage:failure message when error occurs
HippoAdSDK.showFullScreenVideoAd( HIPPO_AD_FULLSCREEN_ID, ( success, errorMessage ) => { // Show later callback
    if ( success ) {
        // Show success
    }
} , () => { // Click callback
        console.log("hippo_sdk", "fullScreen video clicked." );
});

4. Interstitial video ads

a) Ad request

Interstitial ads are shown as a floating window.

// Ad place enabling interstitial video ad
// Parameters:
//    ids:Ad place id array,one or more ids can be transferred into
//    callback: hippoPlacementId:Hippo ad placement id, success:whether successfully loaded
HippoAdSDK.initInterstitialAd([HIPPO_AD_INTERSTITIAL_ID], ( hippoPlacementId, success ) => {
    console.log("hippo_sdk"," fullscreen id:" + hippoPlacementId + " loaded, success:" + success );
});

b)Show Ads

Show reward video ads. Call when triggering ads is needed.

// Show a full-creen video ad
// Show completion callback parameter:
//    success:whether succeeded
//    errorMessage:failure message when error occurs
HippoAdSDK.showInterstitialAd( HIPPO_AD_INTERSTITIAL_ID, ( success, errorMessage ) => { // Show later callback
    if ( success ) {
        // Show success
    }
} , () => { // Click callback
        console.log("hippo_sdk", "Interstitial ad clicked." );
});

5. Banner ads

a)Ads request

// Ad place enabling Banner ad. Ad is shown at the bottom by default, height: 100px
// Parameters:
//    ids:Ad place id array,one or more ids can be transferred into
//    callback:
//         hippoPlacementId:Hippo ad placement id
//         success:whether successfully loaded
HippoAdSDK.initBannerAd([HIPPO_AD_BANNER_ID], ( hippoPlacementId, success ) => { // Show later callback
    console.log("hippo_sdk"," banner id:" + hippoPlacementId + " loaded, success:" + success );
} , () => { // click callback
        console.log("hippo_sdk", "reward video clicked." );
});

b)Show ads

Prepare call back methods on pages to show every ad.

// Show specified Banner
// Show completion callback parameters:
//    success:whether succeeded
//    errorMessage:failure message when error occurs
HippoAdSDK.showBannerAd( HIPPO_AD_BANNER_ID, ( success, errorMessage ) => {
    // Process callback
});

// Hide specified Banner
HippoAdSDK.hideBannerAd( HIPPO_AD_BANNER_ID );

4.Determine whether an adis loaded

Determine whether an ad loaded in certain ad placement:

// Determine whether an ad is loaded
// Parameter:
//    id: single ad placement id
if ( HippoAdSDK.isLoaded( HIPPO_AD_REWARD_ID ) ) {
    // Logic after confirming ad is loaded
}

5. Event tracker

SDK supports event tracker that mainly in Umeng custom events for now.

Notice: To use Umeng custom events, corresponding custom events should be created backstage in advance.

// Event tracker
// Parameters:
//    eventName:event name
//    params:event parameter, must bekey-value object, optional
HippoAdSDK.sendEvent( "test_event_name", {"parma1" : "value1", "param2" : "value2"} );

V. Problem feedback

Android problem

  1. Report that directory is too long after .aar is imported, as follows:

1.png

Solution: Config the export directory of Cocos into the root directory of Disc D.

  1. If reports errors like that certain method is missing, please config as follows:

微信图片_20190428163926.png

Two places in build.gradle need configuration:

  • Config merging method

    android {
      ...
      defaultConfig {
          ...
          multiDexEnabled true
          ...
      }
      ...
    }
    
  • Add dependency

    implementation 'com.android.support:appcompat-v7:28.0.0'