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

Set Alias - Example
	appoxeePlugin.SetDeviceAlias("MyAlias");
...
 	//Matching Callback Method from IAppoxeeCallable, message is true/false (is operation successful)
	void OnSetAlias (String message) {
 	//Your code...
 	}


Get device alias.

public void GetDeviceAlias();
Get device's alias.
Get Alias - Example
	appoxeePlugin.GetDeviceAlias();
...
	//Matching Callback Method from IAppoxeeCallable, message is the Alias
	void OnGetAlias (String message) {
	//Your code after getting the alias
	} 

Remove Alias

public void RemoveDeviceAlias();
Remove device's alias.
Remove Alias - Example
	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

Get Application ID - Example
String appId = appoxeePlugin.GetApplicationID();

public String GetDeviceOsNumber();

Get Operating System Version Number, result as String

Get OS Number - Example
String osNubmer = appoxeePlugin.GetDeviceOsNumber();

public String GetHardwareType();

Get Hardware (Device) Type, result as String

Get Hardware Type
String hardwareType = appoxeePlugin.GetHardwareType();

public String GetDeviceCountry();

Get Device Country, result as String

Get Device Country - Example
String deviceCountry = appoxeePlugin.GetDeviceCountry();

public String GetDeviceOsName();

Get Device Platform, result as String

Get Device Platform - Example
String deviceOsName = appoxeePlugin.GetDeviceOsName();

public bool IsPushEnabled();

Is Device Push Enabled, result as Boolean (true / false)

Is Device Push Enabled - Example
 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

Remove Device Tags - Example
	
	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);

Set Tags to Device
Set Device Tags - Example
	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.

Get Device Tags - Example
    [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.

Get Application Tags - Example
    [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

public void SetPushEnabled(boolean flag);
Soft Opt In / Out for Push .
flag - set true to enable , false to disable
Push Opt Out - Example
	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

Set Custom Field - Example
	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.

Set Custom Field - Example
	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.

Set Custom Field - Example
	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.

Get Custom Field - Example
	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.

Last Push Payload Received - Example
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.


Set Application Badge Number (iOS only)
public void setApplicationBadgeNumber(int bdageNumber);
Set the application badge number, where 0 will remove the badge, and any other number will display it, or update a displayed badge.
Set Application Badge Number
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.