Appoxee SDK - Unity Bridge API
General Warning
Compile time error will happen if you will not implement IAppoxeeCallable in your Main Camera Unity Script.
Android Users - Be aware of the following :
If appoxee-unity-plugin.jar is missing, the AppoxeePlugin will fail at init, raising a null pointer exception, thus all API calls will fail.
Alias
Set device alias.
public void SetDeviceAlias(String alias);
Set device's alias - a unique identifier tor this device
appoxeePlugin.SetDeviceAlias("MyAlias"); ... //Matching Callback Method from IAppoxeeCallable, message is true/false (is operation successful) void OnSetAlias (String message) { //Your code... }
Get device alias.
appoxeePlugin.GetDeviceAlias(); ... //Matching Callback Method from IAppoxeeCallable, message is the Alias void OnGetAlias (String message) { //Your code after getting the alias }
Remove Alias
appoxeePlugin.RemoveDeviceAlias(); ... //Matching Callback Method from IAppoxeeCallable, message is true/false (is operation successful) void OnRemoveAlias(String message) { //Your code after removing the alias }
Device API
Device Information
public String GetApplicationID();
Get Application ID, result as String
String appId = appoxeePlugin.GetApplicationID();
public String GetDeviceOsNumber();
Get Operating System Version Number, result as String
String osNubmer = appoxeePlugin.GetDeviceOsNumber();
public String GetHardwareType();
Get Hardware (Device) Type, result as String
String hardwareType = appoxeePlugin.GetHardwareType();
public String GetDeviceCountry();
Get Device Country, result as String
String deviceCountry = appoxeePlugin.GetDeviceCountry();
public String GetDeviceOsName();
Get Device Platform, result as String
String deviceOsName = appoxeePlugin.GetDeviceOsName();
public bool IsPushEnabled();
Is Device Push Enabled, result as Boolean (true / false)
bool isPushEnabled = appoxeePlugin.IsPushEnabled();
Tags API
Tags are not available for DMC customers yet (coming soon)
Remove Tags
public void RemoveTagsFromDevice(String tags);
Remove Device Tags
appoxeePlugin.RemoveTagsFromDevice("SampleTag1"); ... //Matching Callback Method from IAppoxeeCallable, message is true/false (is operation successful) void OnRemoveDeviceTags (String message) { //Your code after removing a tag }
Set Tags
public void AddTagsToDevice(String tags);
appoxeePlugin.AddTagsToDevice("SampleTag1"); ... //Matching Callback Method from IAppoxeeCallable, message is true/false (is operation successful) void OnSetDeviceTags (String message) { //Your code after setting a tag }
Get Device Tags
public void GetDeviceTags();
Get Device's Tags
JsonUtility usage
As of Unity3D ver 5.3, the Class JsonUtility is introduced to help parse json object. Please refer to Unity's manual here.
If you are using Unity3D version lower than 5.3 , you may use other JSON parsing open source projects, such as JSONObject or SimpleJSON.
[Serializable] public class DeviceTags { public String[] tags; } ... appoxeePlugin.GetDeviceTags(); ... //Matching Callback Method from IAppoxeeCallable, message is Device Tags, as a JSONObject represented as String. void OnGetDeviceTags(String message) { DeviceTags deviceTagsFromJson = JsonUtility.FromJson<DeviceTags> (message); String[] deviceTags = deviceTagsFromJson.tags; //Rest of your code }
Application Tags
public void GetTagList();
Get Application's Tags, from which Device Tags can be taken from.
JsonUtility usage
As of Unity3D ver 5.3, the Class JsonUtility is introduced to help parse json object. Please refer to Unity's manual here.
If you are using Unity3D version lower than 5.3 , you may use other JSON parsing open source projects, such as JSONObject or SimpleJSON.
[Serializable] public class AppTags { public String[] app_tags; } ... appoxeePlugin.GetTagList(); ... //Matching Callback Method from IAppoxeeCallable, message is App Tags, as a JSONObject represnted String. void OnGetAppTags (String message) { AppTags appTagsFromJson = JsonUtility.FromJson<AppTags> (message); String[] appTags = appTagsFromJson.app_tags; //Rest of your code }
Push API
Enable/Disable Push
appoxeePlugin.SetPushEnabled(true); ... //Matching Callback Method from IAppoxeeCallable, message is true/false (is operation successful) void OnPushOptOut (String message) { //Your code after Opting in/out }
Custom Fields API
Set Custom Date Field
public void SetDateField(String fieldName,DateTime fieldValue);
fieldName - name of custom field to set.
fieldValue - value of custom date field to set
appoxeePlugin.SetDateField("LastPlayed", DateTime.now()); ... //Matching Callback Method from IAppoxeeCallable, message is true/false (is operation successful) void OnSetCustomField (String message) { //Your code after setting a custom field }
Set Custom Numeric Field
public void SetNumericField(String fieldName,Decimal fieldValue);
fieldName - name of custom field to set.
fieldValue - value of custom field to set.
appoxeePlugin.SetNumericField("score", 1000); ... //Matching Callback Method from IAppoxeeCallable, message is true/false (is operation successful) void OnSetCustomField (String message) { //Your code after setting a custom field }
Set String Field
public void SetStringField(String fieldName,String fieldValue);
fieldName - name of custom field to set.
fieldValue - value of custom field to set.
appoxeePlugin.SetStringField("Name", "John Doe"); ... //Matching Callback Method from IAppoxeeCallable, message is true/false (is operation successful) void OnSetCustomField (String message) { //Your code after setting a custom field }
Get Custom Field
Gets Custom Field.
public void GetCustomFieldAsString(String fieldName);
fieldName - name of custom field to get.
appoxeePlugin.GetCustomFieldAsString("Name"); ... //Matching Callback Method from IAppoxeeCallable, message is custom field value as String void OnGetCustomField (String message) { //Your code after getting a custom field as callback result. }
Notifications
Last Push Payload Received
public String GetLastPush();
Gets last push payload from last incoming push notification. Deletes it after returning.
String pushPayload = appoxeePlugin.GetLastPush();
Push Notification Callback and Extra Fields Parsing
The method GetLastPush() is the method that should be called every time you wish to handle an incoming push notification. Further explanation on using the Incoming Last Push Notification Method can be found here.
appoxeePlugin.setApplicationBadgeNumber (0); // The application's badge icon will be removed. appoxeePlugin.setApplicationBadgeNumber (2); // The application's badge icon will display a badge count of 2.