Commit ccf4d3d9 王帅

readme

1 个父辈 a68b262d
{
"process_id" : 73968,
"version" : "2019.4.39f1c1",
"app_path" : "/Applications/Unity/Hub/Editor/2019.4.39f1c1/Unity.app",
"app_contents_path" : "/Applications/Unity/Hub/Editor/2019.4.39f1c1/Unity.app/Contents"
}
\ No newline at end of file \ No newline at end of file
...@@ -500,4 +500,4 @@ ScriptsOnlyBuild: ...@@ -500,4 +500,4 @@ ScriptsOnlyBuild:
platform: 9 platform: 9
scenePathNames: scenePathNames:
- Assets/AASDKDemo/Scenes/AASDKDemoScene.unity - Assets/AASDKDemo/Scenes/AASDKDemoScene.unity
playerPath: /Users/ws/Desktop/ZAAUnityDemo/aaaaaaaaa/ccccc playerPath: /Users/ws/Desktop/ZAAUnityDemo
[toc] # Get Started
# 1. Get Started
This guide is intended for publishers who want to integrate the Anti-Addiction system. This guide is intended for publishers who want to integrate the Anti-Addiction system.
# 2. Prerequisites # Prerequisites
- To deploy to iOS - To deploy to iOS
- Xcode 10 or higher - Xcode 10 or higher
- iOS 9.0 or higher - iOS 10.0 or higher
- [CocoaPods](https://guides.cocoapods.org/using/getting-started.html) - [CocoaPods](https://guides.cocoapods.org/using/getting-started.html)
- To deploy to Android - To deploy to Android
- Target Android API level 14 or higher - Not supported at present
- [Access to Demo](https://github.com/yumimobi/AASDK-Unity) ## Download the AntiAddictionSystem Unity plugin
## 2.1 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. 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. 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](https://github.com/yumimobi/AASDK-Unity/releases/download/1.2.0/AASDK.unitypackage) [Download the Plugin](http://59.110.70.54/ZAnti-Addiction/ZAnti-Addiction-Unity/blob/master/ZAnti-AddictionSDK.unitypackage)
[View Source Code](https://github.com/yumimobi/AASDK-Unity)
Or use the `ZAnti-AddictionSDK.unitypackage` file within the project
## 2.2 Import the AntiAddictionSystem Unity plugin ## Import the AntiAddictionSystem Unity plugin
Open your project in the Unity editor. Open your project in the Unity editor.
Select Assets > Import Package > Custom Package and find the AntiAddictionSystem.unitypackage file you downloaded. Select Assets > Import Package > Custom Package and find the AntiAddictionSystem.unitypackage file you downloaded.
...@@ -34,13 +32,13 @@ Make sure all of the files are selected and click Import. ...@@ -34,13 +32,13 @@ Make sure all of the files are selected and click Import.
<img src='resources/import_custom_package.png'> <img src='resources/import_custom_package.png'>
## 2.3 Include the AntiAddictionSystem SDK ## Include the AntiAddictionSystem SDK
The AntiAddictionSystem Unity plugin is distributed with the Unity [Play Services Resolver library](https://github.com/googlesamples/unity-jar-resolver). 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. The AntiAddictionSystem Unity plugin is distributed with the Unity [Play Services Resolver library](https://github.com/googlesamples/unity-jar-resolver). 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. Follow the steps listed below to ensure your project includes the Atmosplay Ads SDK.
### 2.3.1 Deploy to iOS ### Deploy to iOS
No additional steps are required to include the AntiAddictionSystem SDK into the Unity project. No additional steps are required to include the AntiAddictionSystem SDK into the Unity project.
...@@ -48,13 +46,13 @@ After building, open xcworkspace project. ...@@ -48,13 +46,13 @@ After building, open xcworkspace project.
*Note: iOS dependencies are identified using CocoaPods. CocoaPods is run as a post build process step.* *Note: iOS dependencies are identified using CocoaPods. CocoaPods is run as a post build process step.*
### 2.3.2 Deploy to Android ### Deploy to Android
In the Unity editor, select `Assets > External Dependency Manager > Android Resolver > Force Resolve. The Unity Play Services Resolver library will copy the declared dependencies into the `Assets/Plugins/Android` directory of your Unity app. Not supported at present
<img src='resources/force_resolve.png'>
## Config Parametrs
### Config the iOS parameters
## 2.4 Config Parametrs
### 2.4.1 Config the iOS parameters
Add the following parameters into the `info.plist`. Add the following parameters into the `info.plist`.
You can find the `info.plist` in your Xcode project. You can find the `info.plist` in your Xcode project.
...@@ -63,321 +61,79 @@ You can find the `info.plist` in your Xcode project. ...@@ -63,321 +61,79 @@ You can find the `info.plist` in your Xcode project.
```xml ```xml
<key>zgameid</key> <key>zgameid</key>
<string>your game id</string> <string>your game id</string>
<key>zchannelid</key> <key>zchannelid</key>
<string>your channel id</string> <string>your channel id</string>
<key>zplayKey</key>
<string>your zplayKey</string> <key>NSUserTrackingUsageDescription</key>
<string>get hint for IDFA</string>
``` ```
### 2.4.2 Config the Android prameters ### Config the Sign In with Apple
Modify the prameters in `Assets/Plugins/Android/assets/ZplayConfig.xml` file.
<img src='resources/android-setting.png'> In the project editor, add the Sign In with Apple capability to your target.
<img src='resources/signApple_en.png'>
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.
`warning: For GameID, ChannelID parameters in ZplayConfig.xml file, please contact PM for all of these IDs.`
# 3. Integration # 3. Integration
## 3.1 Create AntiAddictionSDK object
```csharp ```csharp
using System; using System;
using UnityEngine; using UnityEngine;
using AntiAddictionSDK.Api; using AntiAddictionSDK.Api;
using AntiAddictionSDK.Common;
using AntiAddictionSDK;
using UnityEngine.SceneManagement;
using UnityEngine.UI; using UnityEngine.UI;
public class AASDKDemoScript : MonoBehaviour { public class AASDKDemoScript: MonoBehaviour
AntiAddictionStytemSDK antiAddictionSDK; {
AntiAddictionStytemSDK antiAddictionSDK;
void Start() public Text statusText;
{ // Start is called before the first frame update
antiAddictionSDK = new AntiAddictionStytemSDK(); void Start()
antiAddictionSDK.OnTouristsModeLoginSuccess += HandleTouristsModeLoginSuccess;
antiAddictionSDK.OnTouristsModeLoginFailed += HandleTouristsModeLoginFailed;
antiAddictionSDK.RealNameAuthenticateSuccess += HandleRealNameAuthenticateSuccess;
antiAddictionSDK.RealNameAuthenticateFailed += HandleRealNameAuthenticateFailed;
antiAddictionSDK.RealNameAuthenticateFailedWithForceExit += HandleRealNameAuthenticateFailedWithForceExit;
antiAddictionSDK.NoTimeLeftWithTouristsMode += HandleNoTimeLeftWithTouristsMode;
antiAddictionSDK.NoTimeLeftWithNonageMode += HandleNoTimeLeftWithNonageMode;
antiAddictionSDK.LeftTimeOfCurrentUserInEverySeconds += HandleLeftTimeOfCurrentUserInEverySeconds;
antiAddictionSDK.RealNameAuthSuccessStatus += HandleRealNameAuthSuccessStatus;
antiAddictionSDK.OnCurrentChannelUserInfo += HandleOnCurrentChannelUserInfo;
antiAddictionSDK.OnUserGroupSuccessResult += HandleOnUserGroupSuccessResult;
antiAddictionSDK.OnClickExitGameButton += HandleOnClickExitGameButton;
}
#region AntiAddictionStytemSDK callback handlers
// Tourist login success event
// Normaly you should ignore this event
public void HandleTouristsModeLoginSuccess(object sender, LoginSuccessEventArgs args)
{
// get the tourist id
String touristsID = args.Message;
print("AntiAddiction---HandleTouristsModeLoginSuccess: " + touristsID);
}
// Tourist login failed event
// Normaly you should ignore this event
public void HandleTouristsModeLoginFailed(object sender, EventArgs args)
{
print("AntiAddiction---HandleTouristsModeLoginFailed");
}
// Real name authentication successful
public void HandleRealNameAuthenticateSuccess(object sender, EventArgs args)
{
print("AntiAddiction---HandleRealNameAuthenticateSuccess");
}
// Real name authentication failed
public void HandleRealNameAuthenticateFailed(object sender, EventArgs args)
{
print("AntiAddiction---HandleRealNameAuthenticateFailed");
}
// The user clicks to exit the game on the real-name authentication interface
public void HandleRealNameAuthenticateFailedWithForceExit(object sender, EventArgs args)
{
print("AntiAddiction---HandleRealNameAuthenticateFailedWithForceExit");
}
// This method will be called when the tourist mode runs out of time
// Will present the real name authentication controller after 3 second
public void HandleNoTimeLeftWithTouristsMode(object sender, EventArgs args)
{
print("AntiAddiction---HandleNoTimeLeftWithTouristsMode");
}
// This method will be called when the nonage mode runs out of time
// Will present the alert controller after 3 second
public void HandleNoTimeLeftWithNonageMode(object sender, EventArgs args)
{
print("AntiAddiction---HandleNoTimeLeftWithNonageMode");
}
// Callback current user info
// leftTime: remaining playable time,-1 means adult, unlimited
public void HandleLeftTimeOfCurrentUserInEverySeconds(object sender, LeftTimeEventArgs args)
{
int leftTime = args.LeftTime;
print("AntiAddiction---HandleTouristsModeLoginSuccess: " + leftTime);
}
// Android When calls the 4.9 UpdateDataReport interface, this callback is returned to notify the game of the successful status of real-name authentication.
public void HandleRealNameAuthSuccessStatus(object sender, EventArgs args)
{
print("AntiAddiction---HandleRealNameAuthSuccessStatus: ");
}
// Android real-name authentication status for Lenovo channel users
// 0:Not real-name authentication
// 1:adults
// 2:nonage
public void HandleOnCurrentChannelUserInfo(object sender, ChannelUserInfoEventArgs args)
{ {
int realNameStatus = args.RealNameStatus; antiAddictionSDK = new AntiAddictionStytemSDK();
print("AntiAddiction---HandleOnCurrentChannelUserInfo: " + realNameStatus); antiAddictionSDK.ZAASDKCompleted += HandleZAASDKCompleted;
} }
//Android After calling the 4.10 CheckUserGroupId interface, it will return the group status of the current user // leftTimeOfCurrentUser = -1 : no time limited
// -1 : unknown // leftTimeOfCurrentUser more than the 0 : left time of current user
// 1 : new user public void LeftTimeOfCurrentUser()
// 2 : old user
public void HandleOnUserGroupSuccessResult(object sender, GroupIdEventArgs args)
{ {
int groupId = args.GroupId; statusText.text = "LeftTimeOfCurrentUser";
print("AntiAddiction---HandleOnUserGroupSuccessResult: " + groupId); if (antiAddictionSDK != null)
{
statusText.text = antiAddictionSDK.LeftTimeOfCurrentUser()+"";
}
} }
// Android only. Call back when the user clicks the exit game button on the real-name authentication page. After the game receives the callback, please exit the game. // allback handlers
public void HandleOnClickExitGameButton(object sender, EventArgs args) // Allow the game to start
public void HandleZAASDKCompleted(object sender, EventArgs args)
{ {
print("AntiAddiction---HandleOnClickExitGameButton: "); statusText.text = "HandleZAASDKCompleted";
statusText.text = "HandleOnClickExitGameButton: "; print("AntiAddiction---HandleZAASDKCompleted");
} }
#endregion
}
```
## 3.2 Show Real-name authentication in the tourist mode (Users can click not to authenticate)
The game should provide a real name authentication button.
Call this method when the user clicks.
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.ShowRealNameView();
}
```
### 3.3 Show Real-name authentication in the tourist mode (Users can't click not to authenticate,only can click exit game)
scenes to be used:
If the user clicks to exit the game, the developer needs to display the real-name authentication obtaining reward interface in - (void)clickForceExitButtonOnRealNameAuthController;; this callback (this interface is implemented by the developer), this interface provides two interactive buttons.
Quit game button: Click this button to quit the game.
Real-name authentication button: Click this button to show the real-name authentication interface provided by the SDK again.
warning: At this time, the timer is paused, and the developer needs to restart the timer in the authentication success callback-(void)resumeTimer;
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.ShowRealNameViewWithForceExit();
}
```
### 3.4 Show the remaining time reminder for tourists and minors
Every time you enter the main interface of the game, show the online time reminder interface for tourists and minor users
This interface is called by the game after initialization.
It is necessary to determine that the SDK is logged in. If the SDK is not logged in, it will be called in the callback of successful SDK login.
Adults do not need to show this interface.
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.ShowAlertInfoController();
} }
``` ```
# Custom interface
The current default screen is as follows:
Portrait
<img src='resources/launch_V.jpg' width=150>
Landscape
<img src='resources/launch_H.jpg' width=350>
### 3.5 Show view details interface (Optional) You can customize this interface by adding image resources:
This interface displays the relevant rules of the Central Propaganda Department on the anti-addiction policy
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.ShowCheckDetailInfoController();
}
```
### 3.6 Detect consumption limit (Optional) `Add an image resource and name it 'ZAA_Launch_Bg' to modify the portrait background image`
Not logged in and minors cannot pay in the game, and the consumption restriction interface will be displayed.
No limit for adults
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.ShowCashLimitedController();
}
```
## 3.7 Set the channel UserId interface (required for Huawei and Lenovo channels) `Add an image resource and name it 'ZAA_Launch_Bg_H' to modify the Landscape background image`
In order to be compatible with Huawei, Lenovo’s channel login and payment SDK is compatible with real-name authentication. The game needs to call the following interface to set the channel UserId after Huawei Lenovo logs in.
Note: Huawei and Lenovo channel anti-addiction function will only be activated after calling the interface below, otherwise it will not activate any function of the anti-addiction SDK `Add an image resource and name it 'ZAA_Launch_StartButton' to modify the Start button`
```java
//userId:User ID returned by Huawei and Lenovo channel login SDK
if (antiAddictionSDK != null)
{
antiAddictionSDK.SetChannelUserId(userId);
}
```
## 4 Other API
<span style="color:rgb(150,0,0);">
<b>Warning:</b> 3.1 and 3.2 is required by Android.
</span>
### 4.1 Application will enter background
<span style="color:rgb(255,0,0);">
<b>warning:</b> IS required by android
</span>
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.GameOnPause();
}
```
### 4.2 Application will enter foreground
<span style="color:rgb(255,0,0);">
<b>warning:</b> IS required by android
</span>
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.GameOnResume();
}
```
### 4.3 Get the status of user authencation
0: No verified
1: Has been verified
```csharp
if (antiAddictionSDK != null)
{
int authenticatedStatus = antiAddictionSDK.IsAuthenticated();
}
```
### 4.4 Get the left time of current user
```csharp
if (antiAddictionSDK != null)
{
// leftTimeOfCurrentUser = -1 : no time limited
// leftTimeOfCurrentUser more than the 0 : left time of current user
int leftTimeOfCurrentUser = antiAddictionSDK.LeftTimeOfCurrentUser();
}
```
##### 4.5 Check user is adult(Optional)
// 0: unknown
// 1: adult
// 2: nonage
```csharp
if (antiAddictionSDK != null)
{
statusText.text = antiAddictionSDK.AgeGroupOfCurrentUser()+"";
}
```
##### 4.6 StopTimer
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.StopTimerInUnity();
}
```
##### 4.7 ResumeTimer
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.ResumeTimerInUnity();
}
```
##### 4.8 Get UserCode(Optional)
<span style="color:rgb(150,0,0);">
<b>Warning:</b> 4.8 is required by Android.
</span>
// Android get UserCode
```csharp
if (antiAddictionSDK != null)
{
string userCode = antiAddictionSDK.GetUserCode();
}
```
##### 4.9 Update user data interface(Optional)
<span style="color:rgb(150,0,0);">
<b>Warning:</b> 4.9 is required by Android.
</span>
// Android update user data method
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.UpdateDataReport();
}
```
##### 4.10 check current user GroupId(Optional)
<span style="color:rgb(150,0,0);">
<b>Warning:</b> 4.10 is required by Android.
</span>
// Android Get the current user's group id. After calling this method, the user's group information will be returned through the event EventHandler<GroupIdEventArgs> OnUserGroupSuccessResult interface.
// zplayId:If not, you can use ""
```csharp
if (antiAddictionSDK != null)
{
antiAddictionSDK.CheckUserGroupId(string zplayId);
}
\ No newline at end of file \ No newline at end of file
[See the English Guide](https://github.com/yumimobi/AASDK-Unity/blob/master/Anti-Addiction-Unity.md) [See the English Guide](http://59.110.70.54/ZAnti-Addiction/ZAnti-Addiction-Unity/blob/master/Anti-Addiction-Unity.md)
# 入门指南 # 入门指南
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
借助防沉迷 Unity 插件,Unity 开发者无需编写 Java 或 Objective-C 代码,即可轻松地在 Android 和 iOS 应用上实现防沉迷的功能。 借助防沉迷 Unity 插件,Unity 开发者无需编写 Java 或 Objective-C 代码,即可轻松地在 Android 和 iOS 应用上实现防沉迷的功能。
该插件提供了一个 C# 界面,用于 Unity 项目中 C# 脚本使用防沉迷功能。 该插件提供了一个 C# 界面,用于 Unity 项目中 C# 脚本使用防沉迷功能。
项目内的`ZAnti-AddictionSDK.unitypackage`文件即为Unity插件。 [点此下载 ZAnti-AddictionSDK.unitypackage](http://59.110.70.54/ZAnti-Addiction/ZAnti-Addiction-Unity/blob/master/ZAnti-AddictionSDK.unitypackage)
或直接使用项目内的`ZAnti-AddictionSDK.unitypackage`文件。
### 导入防沉迷 Unity 插件 ### 导入防沉迷 Unity 插件
...@@ -46,7 +48,10 @@ ...@@ -46,7 +48,10 @@
# 接入前准备 # 接入前准备
##### 配置iOS参数 ##### 配置iOS参数
`请在info.plist中进行如下配置,NSUserTrackingUsageDescription是为了获取IDFA权限,zgameid与zchannelid请联系掌游产品获取` 请在info.plist中进行如下配置:
- NSUserTrackingUsageDescription:是为了获取IDFA权限
- zgameid:请联系掌游产品获取
- zchannelid:请联系掌游产品获取
```xml ```xml
<key>zgameid</key> <key>zgameid</key>
<string>your game id</string> <string>your game id</string>
...@@ -59,7 +64,7 @@ ...@@ -59,7 +64,7 @@
``` ```
##### 配置Apple登录 ##### 配置Apple登录
`由于SDK中使用了Apple登录,所以需要在iOS构建完毕后增加Apple登录权限` `由于SDK中使用了Apple登录,所以需要在iOS构建完毕后增加Apple登录权限`
1.<img src='resources/signApple1.jpg' width=400> 1.<img src='resources/signApple1.jpg' width=400>
...@@ -67,7 +72,7 @@ ...@@ -67,7 +72,7 @@
3.<img src='resources/signApple3.jpg' width=400> 3.<img src='resources/signApple3.jpg' width=400>
你可能会出现如下错误: 你可能会遇到如下错误:
- "xxx" requires a provisioning profile with the Sign in with Apple feature. - "xxx" requires a provisioning profile with the Sign in with Apple feature.
- 点击了加号以后找不到Sign in with Apple的选项 - 点击了加号以后找不到Sign in with Apple的选项
...@@ -153,9 +158,9 @@ public class AASDKDemoScript: MonoBehaviour ...@@ -153,9 +158,9 @@ public class AASDKDemoScript: MonoBehaviour
你可以通过加入图片资源来进行此界面的自定义: 你可以通过加入图片资源来进行此界面的自定义:
`增加图片资源并命名为'ZAA_Launch_Bg'来修改竖屏时的背景图片` `增加图片资源并命名为 'ZAA_Launch_Bg' 来修改竖屏时的背景图片`
`增加图片资源并命名为'ZAA_Launch_Bg_H'来修改横屏时的背景图片` `增加图片资源并命名为 'ZAA_Launch_Bg_H' 来修改横屏时的背景图片`
`增加图片资源并命名为'ZAA_Launch_StartButton'来修改开始按钮` `增加图片资源并命名为 'ZAA_Launch_StartButton' 来修改开始按钮`
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!