update history:
Version | Author | Date | Description |
---|---|---|---|
v1.0.0 | junewong | 2019-05-29 | 1. supported reward API. |
v1.0.6 | junewong | 2019-05-30 | 1. add new callbacks. 1. fixed some issuses; |
v1.0.7 | junewong | 2019-06-06 | 1. adjusted some analysis events. |
v1.1.0 | junewong | 2019-06-11 | 1. update isLoaded method. |
v1.2.0 | junewong | 2019-06-18 | 1. add Unity APIs for new ad ad types: banner, Interstitial and fullscreen video for iOS. |
v1.2.1 | junewong | 2019-06-19 | 1. update for Android’s banner default settings. |
v1.2.2 | junewong | 2019-06-19 | 1. fix some issuses for iOS. |
v1.2.3 | junewong | 2019-06-28 | 1. Add new way for sdk initialization; 1. Support ‘channel’ parameter in config file. |
v1.2.4 | junewong | 2019-06-28 | 1. fix isusse about error callback in iOS platform. |
v1.2.5 | junewong | 2019-07-08 | 1. upgrade the ad sdk to v2.1.0.1 for iOS |
v1.2.6 | junewong | 2019-07-22 | 1. upgrade the ad sdk for Android |
v1.2.7 | junewong | 2019-07-31 | 1. Add the ad clicking callback. |
v1.2.8 | junewong | 2019-08-09 | 1. upgrade the analytics sdk to 3.2.1 for iOS; 1. change the rule for checking if loaded ad. |
v1.2.9 | junewong | 2019-08-14 | 1. add some APIs for user feedback and ratings for iOS; |
v1.3.0 | junewong | 2019-08-15 | 1. upgrade the analytics sdk to 3.3.4 for Android; |
v1.3.6 | junewong | 2019-10-30 | 1. support another ad platoform ‘GDT’ for iOS (need additional framework); 1. upgrade the ‘BU’ ad platform to v2.4.6.7 for iOS; |
v1.3.6 | junewong | 2019-10-31 | 1. update the layout of banner for iOS. |
v1.5.2 | junewong | 2020-02-10 | 1. add splash ad for androd and ios; 1. upgrade the ‘BU’ ad platform to v2.5.7.2; 1. some new features for ABTest; |
v1.5.3 | junewong | 2020-02-13 | 1. support to modify the height of banner in json configuration file. 1. NOTE: should add the implements ‘okhttp’ and ‘cardview’ in android project, see ‘Project configuration’ below. |
v1.5.5 | junewong | 2020-02-19 | 1. ios support the new ad type ‘native express’; |
I. Introduction
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.
II. Preparation
- Download Hippo.zip
hippo-ad-sdk-cn-unity-1.5.5.unitypackage.zip
Or download it from netdisk:
https://drive.google.com/file/d/1OXdwweu3DD4VNkrUxFFYiRvR-f4n1ash/view?usp=sharing
- 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.
- Hippo-SDK has already included the Chinese SDK of Umeng. If the developer has used Umeng SDK before and encounters jar conflict, please delete umeng-analytics-xxx.jar and umeng-common-xxx.jar from your Umeng Analytics
III. Procedures
Integrate Unity plugin of HippoSDK
Add all the files of hippo_sdk.unitypackage of the downloaded Hippo_SDK.zip into Unity ProjectIntegrate SDK configuration files
Add hippo-ads-config.json into the following path under Unity ProjectAssets/StreamingAssets/
The projects in both platforms will contain the .json file.
- Ad demonstration
Please refer to Assets/HippoAdSDKDemo/HippoSDKDemo.cs for actual ad samples
IV. Instructions on using the SDK
1. Initialize SDK
//Register ad event listener
HippoAdSDK.onAdload = new HippoAdSDK.HippoAdLoaded( AdLoaded );
HippoAdSDK.onReward = new HippoAdSDK.HippoRewarded( AdRewarded );
HippoAdSDK.onError = new HippoAdSDK.HippoAdError( AdError );
HippoAdSDK.onClosed = new HippoAdSDK.HippoAdClosed( AdClosed );
HippoAdSDK.registCallBack();
// Initialize sdk, way 1:
// parameters:
// isSuccess: if sdk initiated successfully
// message: the error message.
HippoAdSDK.init((bool isSuccess,string message) => {
Debug.Log("HippoSdk init callback isSuccess:" + isSuccess+", message:"+message);
// next step, start to load ad ...
});
// Initialize sdk, way 2: (No callback, but NOT recommend)
HippoAdSDK.init();
NOTE: Before exploring android project, make sure had add the events ‘onPause’ and ‘onResume’, which descrbed in the section Android Project Configuration .
2. Embed ad
// Create banner ad
HippoAdSDK.createBannerAd( string adUnitId );
// Load interstitial ad
HippoAdSDK.initInterstitialAd( string adUnitId );
// Load rewarded video ad
HippoAdSDK.initRewardedVideoAd( string adUnitId );
// Load fullscreen video ad
HippoAdSDK.initFullScreenVideoAd( string adUnitId );
Notice: Embedded ad will be re-embedded once shown. No manual re-embedding is needed. The ads will be reloaded automatically after each shown.
3. Show ad
// Determine whether an ad is embeded
HippoAdSDK.IsLoadedAd( string adUnitId );
// show banner ad with special position.
HippoAdSDK.showBannerAd( string adUnitId, BannerPosition.BOTTOM );
// hide banner ad
HippoAdSDK.hideBannerAd( string adUnitId );
// show Interstitial ad
HippoAdSDK.showInterstitialAd( string adUnitId );
// show rewarded video ad
HippoAdSDK.showVideoAd( string adUnitId );
// show fullscreen video ad
HippoAdSDK.showFullScreenVideoAd( string adUnitId );
4. Listener callback event
Triggering the ad event will call back the registered event method, e.g.
private void AdLoaded(string adType, string adUnitId)
{
if ( adType == HippoAdSDK.AD_TYPE_BANNER) { // banner ad
// ....
} else if ( adType == HippoAdSDK.AD_TYPE_INTEREST ) { //interstitial ad
// ....
} else if ( adType == HippoAdSDK.AD_TYPE_REWARD ) { //rewarded video ad
// ....
}
}
private void AdRewarded(string adUnitId)
{
// ...
}
private void AdError(string adType, string errorMessage)
{
// ...
}
private void AdClosed(string adType, string adUnitId)
{
// ...
}
private void AdClicked(string adType, string adUnitId)
{
// ...
}
5. Analysis events
All events will be recorded into the analysis platform ‘Umeng.com’ . This is an optional API.
// customEventName : the name of custom event.
// params : the attributes of event (optional).
HippoAdSDK.sendEvent(string customEventName)
HippoAdSDK.sendEvent(string customEventName, Dictionary<string, string> params);
V. Problem with Integrating
1. Problem with main threads.
All the ads callbacks received in Unity code will not work in the UI thread, watch the tool and demo below if need to do something with UI or audio actions.
UnityMainThreadDispatcher-master.zip(8 kB)
V. Project configuration
iOS Project configuration
iOS Project Runtime environment
- Support iOS 8.X or higher;
- SDK compiling environment Xcode 9.4, Base SDK 11.1;
- Architectures supported: i386, x86-64, armv7, armv7s, arm64
After Unity has exported the iOS project, please check the following project configurations:
1. Network permission configuration
All existing SDK APIs support HTTPS, but sometimes the main ad material may be non-HTTPS, and to solve this:
Go to the setting of the project’s plist and expand the Information Property List by clicking the ‘+’
Add App Transport Security Settings. Click the arrow on the left to expand then the ‘+’ on the right to automatically add the option of Allow Arbitrary Loads. Modify its value to ‘YES’
2. Check whether the following libraries exist, and add if not:
In the project, click TARGETS → Build Phases and locate Link Binary With Libraries. Click ‘+’ and add any dependent library missing from the following:
- 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
- PhotoKit.framework
3. Add argument in ‘Other Linker Flags’
Go to Build Settings → Other Linker Flags and add the argument “-ObjC”. SDK supports - all_load at the same time.
Android Project Configuration
Runtime Environment Configuration
- add the implements in build.gradle
allprojects {
repositories {
...
google()
jcenter()
...
}
}
dependencies {
...
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
...
}
If the error below had occur, should export the android project, and add some configurations:
Add the multiDex support:
android {
...
defaultConfig {
...
multiDexEnabled true
...
}
...
}
and the implements:
dependencies {
...
implementation 'com.android.support:appcompat-v7:28.0.0'
...
}
For the Hippo Analytics
Need to call the corresponding APIs in each Activity lifeacycle: call HippoAdSdk.OnAppResume(Activity) in the Activity’s onResume (), and call HippoAdSdk. OnAppPause (Activity) in the Activity’s onPause();
If you did not develop with native Android project, call the APIs at the enter/exit location for each page, as shown below:
- If work in android project:
public class MainActivity extends AppCompatActivity {
…………
@Override
protected void onResume() {
super.onResume();
HippoAdSdk.onAppResume(this);
}
@Override
protected void onPause() {
super.onPause();
HippoAdSdk.onAppPause(this);
}
…………
}
PS: How to custom the main Activity in uity project, see:
https://docs.unity3d.com/Manual/AndroidUnityPlayerActivity.html
- If work in unity project, add the codes in matched events (when App in foreground and background) for the game:
// resume when entering the game
HippoAdSDK.onAppResume();
// resume when exiting the game
HippoAdSDK.onAppPause();
VI. NOTE
1.Test
The ads can only shown in China or Japan. Use a chinese VPN, or build a ipa file so we can help to test it.
Suggest installing a Chinse VPN by searching ‘小马加速’ on AppStore, which can help to visit the Chinese network (free on first 7 days). Try to change region into American or Canadian zone if search nothgin.
2.Error code
Code | ** |
---|---|
20000 | OK. |
20001 | No ads. (Or may not be in China or Japan?) |
40006 | The ad unit id is invalid. |
40016 | The appId is not related to the ad unit id. |
40018 | The package name is not correct. |
40019 | The ad type is not related to the ad id. |
50001 | Server error. |
3.Errors
3.1 Error message “found an unexpected mach-o header code 0x72613c21”.
Check the ‘Embedded Binaries’ settings ? Do not add our sdk framework into there.
3.2 ld: symbol(s) not found for architectrue arm7s
Remove all architectures excpet arm64 in build settings: