Preface :
- GooglePlayServices version must be at least 8.1.
- The Plugin contains Appoxee SDK version 2.6.1 .
Integration Instructions :
Phase 1
- Download the Appoxee Android Unity Plugin Zip file for the Download Page.
- Extract the zip file to path :
UnityProjectName/Assets
- Replace in AndroidManifest.xml the "YOUR_PACKAGE_NAME" placeholder to your reverse-domain package name as you set in the Unity IDE
- Verify that this is the directory structure and content after extracting :
- UnityProjectName/Assets/Plugins/AppoxeeAndroidBridge.cs
- UnityProjectName/Assets/Plugins/IAppoxeeCallable.cs
- UnityProjectName/Assets/Plugins/Android/appoxee-sdk.jar
- UnityProjectName/Assets/Plugins/Android/appoxee-unity-plugin.jar
- UnityProjectName/Assets/Plugins/Android/AppoxeeSDK/AndroidManifest.xml
- UnityProjectName/Assets/Plugins/Android/AppoxeeSDK/project.properties
- UnityProjectName/Assets/Plugins/Android/AppoxeeSDK/libs
- UnityProjectName/Assets/Plugins/Android/AppoxeeSDK/res
- UnityProjectName/Assets/Plugins/Android/google-play-services_lib
- Open your Unity project.
Phase 2
Your MainCameraScript class must implement IAppoxeeCallable in order to receive the results of the API calls.
- Your MainCameraScript class should hold a member of the AppoxeeAndroidBridge in order to use the different API calls after initializing it, using the Factory method.
In order to initialise the Appoxee Unity Bridge, call AppoxeeAndroidBridge.CreateAppoxeeAndroidBridge() , passing it your gameObject, Your SDK Key & Secret Key. Do so in your onEnable() method.
SDK Key & Secret - Do Not Confuse Platforms!
Make sure the Key & Secret under your iOS Application in the Appoxee Dashboard is used for your iOS Unity App.
Make sure the Key & Secret under your Android Application in the Appoxee Dashboard is used for your Android Unity App.
Do not mix between them!- In your onStart() method, call AppoxeeReportActivate() in order to signal to the SDK that the App is now in foreground. This is crucial for analytics.
- In your onDestroy() method, call AppoxeeReportBackground() in order to signal to the SDK that the App is now in background, This is crucial for analytics.
- Please Note : if your AppoxeeAndroidBridge member is NULL after calling the Factory method, the appoxee-unity-plugin.jar is MISSING, thus resulting a crash on each API call.
The following code snippet shows the MainCameraScript class as step 1 - 5 explain :
Init AppoxeeAndroidBridgeusing UnityEngine; using System; ... public class MainCameraScript : MonoBehaviour,IAppoxeeCallable<String> { ... private AppoxeeAndroidBridge AppoxeePlugin; //Keep as field/member in order to use the API. if Null, API calls will cause a crash in runtime. ... void OnEnable() { if (AppoxeePlugin == null) { AppoxeePlugin = AppoxeeAndroidBridge.CreateAppoxeeAndroidBridge(this, "YOUR_SDK_KEY", "YOUR_SECRET_KEY"); } } ... void Start () { // AppoxeePlugin.AppoxeeReportActivate () must be called to report that the app was activated, crucial for analytics if (AppoxeePlugin != null) AppoxeePlugin.AppoxeeReportActivate (); } ... void OnDestroy() { // AppoxeePlugin.AppoxeeReportBackground () must be called to report that the app was deactivated, crucial for analytics if (AppoxeePlugin != null) AppoxeePlugin.AppoxeeReportBackground (); } ... }
- API Samples can be seen in the following link