Anti-Addiction-Unity.md 4.6 KB

Get Started

This guide is intended for publishers who want to integrate the Anti-Addiction system.

Prerequisites

  • To deploy to iOS

    • Xcode 10 or higher
    • iOS 10.0 or higher
    • CocoaPods
  • To deploy to Android

    • Not supported at present

Download the AntiAddictionSystem Unity plugin

The AntiAddictionSystem Unity plugin enables Unity developers to easily serve AntiAddictionSystemSDK on Android and iOS apps without having to write Java or Objective-C code. The plugin provides a C# interface for requesting ads that is used by C# scripts in your Unity project.

Use the links below to download the Unity package for the plugin or to take a look at its code on GitHub.

Download the Plugin

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

Import the AntiAddictionSystem Unity plugin

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

Make sure all of the files are selected and click Import.

Include the AntiAddictionSystem SDK

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.

Follow the steps listed below to ensure your project includes the Atmosplay Ads SDK.

Deploy to iOS

No additional steps are required to include the AntiAddictionSystem SDK into the Unity project.

After building, open xcworkspace project.

Note: iOS dependencies are identified using CocoaPods. CocoaPods is run as a post build process step.

Deploy to Android

Not supported at present

Config Parametrs

Config the iOS parameters

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

warning: You can contact PM for all of these IDs .

    <key>zgameid</key>
    <string>your game id</string>

    <key>zchannelid</key>
    <string>your channel id</string>

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

Config the 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.

3. Integration

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;
    }

    // leftTimeOfCurrentUser = -1 : no time limited
    // leftTimeOfCurrentUser more than the 0 : left time of current user
    public void LeftTimeOfCurrentUser()
    {
        statusText.text = "LeftTimeOfCurrentUser";
        if (antiAddictionSDK != null)
        {
            statusText.text = antiAddictionSDK.LeftTimeOfCurrentUser()+"";
        }
    }

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

# Custom interface The current default screen is as follows: Portrait

Landscape

You can customize this interface by adding image resources:

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