Skip to content
“yangfengbang” edited this page Aug 10, 2021 · 9 revisions

1. Get Started

This guide is intended for publishers who want to integrate the AntiAddictionSystem.

1.1 Prerequisites

OS: Windows, Mac, Linux
Android SDK: > 4.4(API level 19)
IDE: Eclipse with ADT (ADT version 23.0.4) OR Android-Studio
Java: > JDK 7

2. Import the AntiAddictionSystem SDK

2.1 Android studio

add AntiAddictionSystem SDK adapters dependencies.

dependencies {
    // AntiAddictionSDK
    implementation "com.yumimobi.ads.sdk:antiaddiction:1.1.1"

add maven central to project build.gradle

allprojects {
    repositories {
        mavenCentral()
        maven { url 'https://repo1.maven.org/maven2/' }
    }
}

2.2 Proguard

If your project turn on minifyEnabled, add the following to the proguard file.

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,Synthetic,EnclosingMethod
-keep class com.zplay.android.addiction.prevention.** { *;}

3. Configure the parameters required for AntiAddictionSystem SDK

3.1 Download ZplayConfig.xml and add to you project assets

antiAddiction-ZplayConfig

Download ZplayConfig.xml

3.2 Configure the ZplayConfig.xml

antiAddiction-ZplayConfig1
For the GameID, ChannelID, Zpay_SDK_KEY parameters in the ZplayConfig.xml file, please contact Zplay products

4 Integration

4.1 Init AntiAddictionSDK

loginCallback = new ZplayLoginCallback() {
    @Override
    public void loginSuccess(String uid, String token, String userName, String loginType) {
        // Tells the delegate that user login success.
    }

    @Override
    public void loginHasBeenShown() {
        // Tells the delegate that a login view has been shown.
    }

    @Override
    public void loginCancel() {
        // Tells the delegate that a login view has been dismissed.
    }

    @Override
    public void loginFail() {
         // Tells the delegate that user login failed.
    }
};

userAuthVcCallback = new ZplayUserAuthVcCallback() {
    @Override
    public void userAuthVcHasBeenShown() {
         // Tells the delegate that an auth view has been shown.
    }

    @Override
    public void userAuthSuccess() {
         // Tells the deledate that user auth success.
    }
};
// Warning view callback
// You should listen to the following callbcaks and modify your app's UI logic.
warningCallback = new ZplayWarningCallback() {

    @Override
    public void warningHasBeenShown() {
        // Tells the delegate that an warning view has been shown.
    }

    @Override
    public void userClickLoginButtonInPayment() {
        // Users cannot purchase in guest mode, so SDK will present a warning view.
        // when user click the login button in warning view, you should show the login view.
        // User can close the login view and continue the game.
    }

    @Override
    public void userClickLoginButtonInNoTimeLeft() {
        // [Important] Receive this callback means the user has been in the game as a guest for a long time
        // [Important] SDK pops up a pop-up window for users to log in to continue or exit the game
        // [Important] The game should requires the user to log in, and the APP should handle the logic that the user cannot continue the game without login.
    }


    @Override
    public void userClickQuitButton() {
        // Tells the delegate that user click the quit button in warning view.
    }

    @Override
    public void userClickConfirmButton() {
        // Tells the delegate that user click confirm button in warning view. , game does not need to be processed
    }
};

ZplayAddictionSDK.init(Activity, loginCallback, userAuthVcCallback, warningCallback);

4.2 Show privacy policy

Call this method when the app start. Make sure you call this method every time what app start.

ZplayAddictionSDK.showPrivacyPolicy(Activity, new ZplayPrivacyPolicyCallback() {
    @Override
    public void privacyPolicyShown() {
    // Tells the delegate that a privacy policy view has been shown.
    }

    @Override
    public void userAgreesToPrivacyPolicy() {
        // Tells the delegate that the user has been agreed the private policy.
    }

    @Override
    public void userDisagreesWithPrivacyPolicy() {
        // Tells the delegate that the user has been disagrees the private policy.
    }
});

4.3 Login API

Warning: The application must choose one of the following login methods to log in. After login success, the anti-addiction SDK will automatically pop up the user real-name authentication interface. We provide 4 login api as the following.

4.3.1 Anti Addiction SDK login UI

If your APP has no login function and no login interface, use the login function of the anti-addiction SDK to call this interface.

You only need to monitor loginSuccess (), loginFail () to determine whether the user has logged in successfully, and then execute the application logic.

ZplayAddictionSDK.login(Activity);

4.3.2 Login with username and password

If your APP has a login UI, just use our login interface

If the application uses the login interface designed by yourself. You can pass the account and password to the anti-addiction SDK by the following interface.

You only need to monitor loginSuccess (), loginFail () to determine whether the user has logged in successfully, and then execute the application logic.

//username:account
//password:password
ZplayAddictionSDK.loginWithUserName(Activity, userName, password);

4.3.3 Login with third-party SDK

If your APP has access to WeChat SDK, QQ SDK, or the other SDK, you need to call this interface.

After login with Wechat or QQ, you can get one unique user ID. Then pass the unique ID to anti-addiction SDK by the following interface.

You should monitor loginSuccess (), loginFail () to determine whether the user has logged in successfully, and then execute the application logic.

//token: unique id return by other SDK
//otherID: unique id return by other SDK
//platformName: contact PM for this parameter
ZplayAddictionSDK.loginWithPlatformToken(Activity, token, otherID, platformName);

4.3.4 Login with Zplay SDK

If you use the SDK developed by Zplay, you can get a ZplayID after login. Pass the ZplayID to anti-addiction SDK.

//zplayID: return by zplay sdk.
ZplayAddictionSDK.loginWithZplayID(Activity, zplayId);

4.4 Real-name authentication in the tourist mode

Before Login success, user is in tourist mode. In this mode, you can show the auth view by following interface.

ZplayAddictionSDK.showVisitorUserAuthentication(Activity);

4.5 Login out

If user can change account in your app, you should call the following interface before account changing.

ZplayAddictionSDK.logout(this, new ZplayLogoutCallback() {
    @Override
    public void logout(Activity activity) {
        // Tells the delegate that user login out.
    }
});

4.6 Payment API

According to Chinese regulations, there is a limit on the single payment amount and the cumulative monthly payment amount of minors in the game. So before user payment, the interface checkNumberLimitBeforePayment() needs to be called.

If the user pays successfully, you should call reportNumberAfterPayment().

4.6.1 Check if this user purchase can be paid

// payNumber: Payment amount, Unit penny
ZplayAddictionSDK.checkNumberLimitBeforePayment(Activity, payNumber, new ZplayCheckCallback() {
    @Override
    public void onCanPay() {
        // Tells the delegate user can purchase in your app.
    }

    @Override
    public void onProhibitPay(String errorMsg) {
        // Tells the delegate user can't purchase in your app.
    }
});

2.6.2 Report to anti-AddictionSDK after user pays successfully

// payNumber: Payment amount, Unit penny
ZplayAddictionSDK.reportNumberAfterPayment(Activity, payNumber);

4.7 Other API

4.7.1 Get user login status

// notlogin: Unknow
// visitor: tourist mode 
// user: regular user
String loginStatus = ZplayAddictionSDK.getLoginType(Activity);

4.7.2 Get user auth status

UserVerifiedType userAuthenticationIdentity =  ZplayAddictionSDK.getUserVerified(MainActivity.this);

if(userAuthenticationIdentity == UserVerifiedType.UserAgeUnknow){
    //unknow
}else if(userAuthenticationIdentity == UserVerifiedType.UserAdult){
    //adult
}else{
    //Under 18
}

4.7.3 Application will enter background(Required)

When the user presses the home button to exit the game to the background, please call the following interface

Warning: Call the following api when application will enter background.Not calling will cause the anti-addiction SDK to calculate the game time error
ZplayAddictionSDK.onPause();

2.7.4 Application will enter foreground(Required)

Warning: Call the following api when application will enter foreground.Not calling will cause the anti-addiction SDK to calculate the game time error
ZplayAddictionSDK.onResume();

Clone this wiki locally