Unity Integration for Appoxee Standalone
This part of the documentation extends the integration process of Appoxee's native library into the Unity3D world.
Dual Plugin Integration
If your Unity project is being developed with IDE version under 5, please note that using both of our Android & iOS plugins (or any 3rd party plugin) will cause an issue known to Unity3D users, which is described in this URL : iOS build loads assembly from Assets/Plugins/Android. Why? Build fails.
There is also mentioning of this (with an alternate solution) in Stack Overflow - Unity Plugin for both iOS and Android Failing AOT for iOS due to AndroidJavaObject
Integration Instructions :
Phase 1
- Download the Appoxee Unity Plugin Zip file for the EULA Page.
- Extract the zip file to path :
UnityProjectName/Assets
- For Android Only : 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/AppoxeePlugin.cs
- UnityProjectName/Assets/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
- UnityProjectName/Assets/Plugins/ios/AppoxeePlugin.h + m
- UnityProjectName/Assets/Plugins/ios/AppoxeePluginDelegate.h + m
- UnityProjectName/Assets/Plugins/ios/UnityAppController+AppoxeeUnity.h + m
- UnityProjectName/Assets/Plugins/ios/AppoxeeSDK.framework
- UnityProjectName/Assets/Plugins/ios/AppoxeeSDKResources.bundle
- 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 AppoxeePlugin in order to use the different API calls after initializing it, using the Factory method.
In order to initialise the Appoxee Unity Bridge, call AppoxeePlugin.CreateAppoxeeUnityBridge() , passing it your gameObject, Your SDK Key & Secret Key . Do so in your onStart() method.
SDK Key & Secret - Do Not Confuse Platforms!
iOS - Make sure the Key & Secret under your iOS Application in the Appoxee Dashboard is used for your iOS Unity App, and is passed to the plugin via a AppoxeeConfig.plist file.
Android -Make sure the Key & Secret under your Android Application in the Appoxee Dashboard is used for your Android Unity App, and is passed as a parameter to the initialization method.
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.
- Android Users - Please Note : if your AppoxeePlugin 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 AppoxeePlugin unityBridge; //Keep as field/member in order to use the API. if Null, API calls will cause a crash in runtime. ... // Use this for initialization void Start () { if (myBridge == null) { Debug.Log ("UNITY: Start() calling constructor"); #if UNITY_IOS // No need to pass an SDK key & App secret on iOS. // Values should be passed via and AppoxeeConfig.plist file, in your Xcode project. myBridge = AppoxeePlugin.CreateAppoxeeUnityBridge(this, "", ""); #elif UNITY_ANDROID myBridge = AppoxeePlugin.CreateAppoxeeUnityBridge(this, "11111.11", "22222.22"); #endif } } // If Application is on it's way to the background / out of focus, must report deactivation for analytics void OnApplicationPause(bool pauseStatus) { if (pauseStatus) { #if UNITY_ANDROID if (unityBridge != null) { unityBridge.ReportDeactivation(); } #elif #endif } } // If Application is in focus/back in foreground, must report activation for analytics void OnApplicationFocus(bool focusStatus) { if (focusStatus) { #if UNITY_ANDROID if (unityBridge != null) { unityBridge.ReportActivation(); } #elif #endif } } ... }
- iOS Only
- Open your Xcode project.
Add UserNotifications.framework to your projects 'build phases' -> 'Link Binary With Libraries'.
- create a
.plist
file (File -> New -> File... Recource -> Property List) and name it AppoxeeConfig.plist. Provide your SDK key, and other relevant settings.
AppoxeeConfig.plist<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>sdk</key> <dict> <key>sdk_key</key> <string>123456789.00</string> <key>is_eu</key> <!-- Optional, indicate if account is EU / US --> <false/> <key>open_landing_page_inside_app</key> <!-- Optional, indicate if landing page should open inside the app or via Safari --> <false/> </dict> </dict> </plist>
- API Documentation can be seen in the following link