Anti-Addiction-Unity.md 5.7 KB

What is ZAnti-AddictionSDK

For games released in China, one of the rules that must be followed is real-name authentication before playing and a limit on how long minors can play.

Using this sdk, you can easily implement this feature.

Platform

  • iOS

    • Xcode 10 or higher
    • iOS 10.0 or higher
    • CocoaPods
  • Android

    • Not supported

The AntiAddictionSystem Unity plugin is distributed with the Unity Play Services Resolver library. This library is intended for use by any Unity plugin that requires access to Android specific libraries (e.g., AARs) or iOS CocoaPods. It provides Unity plugins the ability to declare dependencies, which are then automatically resolved and copied into your Unity project.

Detailed Steps

1. Download the Plugin

Download the Plugin

Or use the ZAnti-AddictionSDK.unitypackage file within the project

2.Import plugin

Open your project in the Unity editor.
Select Assets > Import Package > Custom Package and find the ZAnti-AddictionSDK.unitypackage file you downloaded.

Import

3. Build iOS Project

4. Run CocoaPods

After the build is completed, enter the project directory and execute pod install

This step depends CocoaPods

5. Necessary Configuration

info.plist

Add the following parameters into the info.plist. You can find the info.plist in your Xcode project.

  • zgameid:You can contact PM for this
  • zchannelid:You can contact PM for this
    <key>zgameid</key>
    <string>your game id</string>

    <key>zchannelid</key>
    <string>your channel id</string>
Capabilities - Sign In with Apple

In the project editor, add the Sign In with Apple capability to your target.

You might get the following error:

  • "xxx" requires a provisioning profile with the Sign in with Apple feature.
  • can't find Sign In with Apple in capability

It might have something to do with Certificates, Identifiers & Profiles,You can contact the PM to try to resolve the problem.

How to use

AntiAddictionSDK
using System;
using UnityEngine;
using AntiAddictionSDK.Api;
using AntiAddictionSDK.Common;
using AntiAddictionSDK;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class AASDKDemoScript: MonoBehaviour
{
    AntiAddictionStytemSDK antiAddictionSDK;
    public Text statusText;
    // Start is called before the first frame update
    void Start()
    {
        antiAddictionSDK = new AntiAddictionStytemSDK();
        antiAddictionSDK.ZAASDKCompleted += HandleZAASDKCompleted;
    }

    // callback handlers
    // Allow the game to start
    public void HandleZAASDKCompleted(object sender, EventArgs args)
    {
        statusText.text = "HandleZAASDKCompleted";
        print("AntiAddiction---HandleZAASDKCompleted");
    }

    // callback handlers
    // This is the result callback after use AntiAddictionStytemSDK - checkPayWithAmount
    // Receipt of this callback indicates that payment can be made
    public void HandleZAASDKCheckPayCompleted(object sender, EventArgs args)
    {
        String infoString = "--- The check passes, you can pay ";
        print(infoString);
        statusText.text = infoString;
    }
}

Optional Method

1. Get the status of user authencation

0=>No verified

1=>Has been verified

2=>Being verified

3=>Verified failure

antiAddictionSDK.IsAuthenticated()

2. Check user is adult:

1: adult

2: nonage

antiAddictionSDK.AgeGroupOfCurrentUser()

3. remaining time for minors (s):

antiAddictionSDK.LeftTimeOfCurrentUser()

In-App Purchase check

Because the amount of money minors can spend on the game is limited, they need to check before making in-app purchases.

  1. Use: AntiAddictionStytemSDK.checkPayWithAmount(String amount)
  2. If you receive the following callback, you can proceed with the In-App Purchase as normal: HandleZAASDKCheckPayCompleted
  3. If callback is not received, payment cannot be made. Specific reasons will be prompted by the SDK.
  4. After the payment is successful, you need to use the following methods to report the specific payment amount: HandleZAASDKCheckPayCompleted

Optional configuration

1. IDFA

Getting IDFA helps optimize the user experience.

Add the following parameters into the info.plist:

  • NSUserTrackingUsageDescription:get hint for IDFA
    <key>NSUserTrackingUsageDescription</key>
    <string>get hint for IDFA</string>

2. Change SDk Background Image

The current default screen is as follows: Portrait

Landscape

You can change this interface by adding image under the 'Assets/StreamingAssets' path:

After the change:

Add an image resource and name it 'ZAA_Launch_Bg' to modify the portrait background image

Add an image resource and name it 'ZAA_Launch_Bg_H' to modify the Landscape background image

Add an image resource and name it 'ZAA_Launch_StartButton' to modify the Start button