로딩중입니다
Live Operation: Target Push Integration: Unity Android
5/30/2016 10:28:05 PM

Live Operation Service

Live Operation is a service to send push notifications to targeted app users through filtering.

App admins can enhance the convenience of the advanced push system by integrating with Live Operation.


Notice
  1. IGAW General Integration must be set in order to integrate Live Operation add-on. [IGAW General Integration: Unity Android]
  2. In order to integrate Live Operation, IgawLiveOps~*_thirdparty.jar file must be included in Unity project.  [SDK Installation: Unity]
  3. Google Play Services must be integrated to integrate Live Operaion [Google Play Services Setting
  4. Latest version of android-support-v4.jar must be included in the project. (Higher than ver21) [Google Guide]
* Update Info *
If you use LiveOps 1.2.9 version(Jul. 30th. 2015 updated), please check below migration guide.
[Live Operation Migration: Android]



AndroidManifest.xml

Edit the Android Manifest file for the Live Operation integration.

Other than the app key, hash key, and authorization established in the general integration, add  Extra Authorization and Push-related Receiver & Service.


Add meta tag to integrate Google Play Services.

<meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />


Add required permissions for Live Operation within <manifest></manifest> tag.

<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<!-- Higher than LiveOps v1.3.6 don't need this process. -->
<uses-permission android:name="android.permission.GET_TASKS"/>

<!-- C2DM Permission -->
<permission android:name="MY_PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel = "signature" />
<uses-permission android:name="MY_PACKAGE_NAME.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

Enter the package name of the integrated project in MY_PACKAGE_NAME in the C2DM permission settings.


Register the required receiver and service for Live Operation within the <application></application> tag.

<!-- IGAWorks GCM Broadcast Receiver -->
<receiver android:name="com.igaworks.liveops.pushservice.LiveOpsGCMBroadcastReceiver"
    android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="MY_PACKAGE_NAME" />
    </intent-filter>
</receiver>

<!-- IGAWorks Push Service -->
<service android:enabled="true" android:name="com.igaworks.liveops.pushservice.GCMIntentService" />

<!-- Client Push App Receiver -->
<receiver android:name="com.igaworks.liveops.pushservice.LiveOpsReceiver"
    android:permission="MY_PACKAGE_NAME.permission.C2D_MESSAGE">
    <intent-filter>
        <action android:name="com.igaworks.liveops.pushservice.CLIENT_PUSH_RECEIVE"/>
    </intent-filter>
</receiver>

Enter the package name of the integrated project in MY_PACKAGE_NAME in the receiver settings.


Are you looking to participate as an adPOPcorn advertiser?

If you wish to run CPI advertisements through the adPOPcorn ad network, you should register the Google installation receiver.

[IGAWorks Google Install Receiver Guide]



Basic Integration / Server Push

To use Live Operation, the basic integration should be proceeded through the API below from the app's main activity. Once integration is completed, the server push becomes activated and the read status of your push notifications can be tracked.


  • Igaw~.Common.setUserId(string userId);
  • Igaw~.LiveOps.initialize();
  • Igaw~.LiveOps.resume();
public class MySampleScene : MonoBehavior {
 
    void Start () {
	//Set user ID
	IgaworksUnityPluginAOS.Common.setUserId("user100001");
	//Initialize Live Operation
	IgaworksUnityPluginAOS.LiveOps.initialize ();
    }

    void OnApplicationPause(bool pauseStatus){
		
    	if (pauseStatus) {
		IgaworksUnityPluginAOS.Common.endSession();
	} else {
		IgaworksUnityPluginAOS.Common.startSession();
		// Enable Live Operation
		IgaworksUnityPluginAOS.LiveOps.resume();
	}
    }
}  
The Live Operation service runs the activity registered as the Launcher in the Android Manifest when the push message is read.
User identification value must be registered by using the setUserId API so that it can be included in the push notifications being sent out.
If a Korean character, spacing, or special character should be used as user identification value, it must be encoded. 
+ When the application changes to foreground state, you have to call resume api in order to track push open.

Input User Identifier Value

User Identifier Value is to verify each user on Live Operation.


    Notice

  1. One user should only have one unique value, not variable. 
  2. Must not contain any personal information(email, name, phone number, username).
  3. Must go through URL encoding if contains Korean, special character, or black space.
  4. Must be set before Igaw~.LiveOps.initialize API is called.

Follow the above notice when input the User ID value.

IgaworksUnityPluginAOS.Common.setUserId("user100001");



Deep link Integration / Server Push

Live Operation's Server Push offers deep link feature.

Deep Link enables users to perform an action defined in the Deep Link data when receiving and reading a push message.

A set of Deep Link data is created and managed in the Live Operation Admin page. Register data as three types:

TypeFormat
URL (Http type)http://www.igaworks.com
URL (Custom Scheme type)myApp://activity.com
Json type{"key":"value", "igaworks":"sample"}


  • URL (http type) & Json 

Deep link feature overrides Android's onNewIntent function and implement depending on the link type.
public class MainActivity extends Activity{ 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
 
		IgawCommon.startApplication(this);
		IgawCommon.setUserId("userid_123123123");
		IgawLiveOps.initialize(MainActivity.this);
 
		//transfer intent to onNewIntent listener.
		onNewIntent(getIntent());
	}
 
	@Override
	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);
		/* Depending on the type of the deep line, implement referring to the followings. */
 
		/* 1. Implementing App scheme type(myApp://deepLinkAction) deep link
		 * 
		 * Execute the scheme action transferred to the deep link.
		 * IgawLiveOps.onNewIntent(MainActivity.this, intent);
		 */
 
		/* 2. Implementing Json string type({“url”:”deepLinkAction”}) deep link
		 * 
		 * Extract the Json string transferred to the deep link and convert it to the object.
		 * String jsonStr = intent.getStringExtra("com.igaworks.liveops.deepLink");
		 * JSONObject jsonObj;
		 * try {
		 *     jsonObj = new JSONObject(jsonStr);
		 *     //Parse the Json object to implement to run the activity.
		 * } catch (Exception e) {
		 *     // TODO: handle exception
		 * }
		 */
	}
}

  • URL (Custom Scheme type)

Add IgawLiveOpsPushMessageLauncherActivity at Manifest file. And when the push message is clicked, input scheme and host at <intent-filter></intent-filter> tag of the activity going to be opened. If Custom Scheme is myApp://activity.com, Input myApp at scheme and activity.com at host.

<!-- Add IgawLiveOpsPushMessageLauncherActivity. -->
<activity 
	android:name="com.igaworks.liveops.pushservice.IgawLiveOpsPushMessageLauncherActivity" 
	android:permission="MY_PACKAGE_NAME.permission.C2D_MESSAGE"
	android:noHistory="true"/> 


<!-- Apply it to Activity that will be applied to the deep link. -->
<activity android:name="com.example.DeeplinkActivity">
	<intent-filter>
	<data android:scheme="myApp" android:host="activity.com" />
		  <action android:name="android.intent.action.VIEW" />
      		  <category android:name="android.intent.category.DEFAULT" />
      		  <category android:name="android.intent.category.BROWSABLE" />
	</intent-filter>            
</activity>
+ Put the package name you at MY_PACKAGE_NAME that you are integrating.


Client Push

Live Operation provides a client push feature where you can create and use push messages by using the API directly from the client.

Generally, client push creates and displays push messages in case the user matches the pre-designated conditions of the app.

Moreover, it can be used as a way to create push messages through server events if communication between the developer's server and the app is available.

In the client push, Normal Push and Big Text Push are supported.


      General Client Push

General client push is comprised of basic texts.
Push messages can be created and displayed through the setNormalClientPushEvent API.
IgaworksUnityPluginAOS.LiveOps.setNormalClientPushEvent(
	1,                 	// Delay seconds. Seconds before sending
	"Let’s play now!",      // The message that will be sent
	1,			// Event ID, a value needed when canceling.
	false			// Whether it will be displayed even when the app is running
);

      Big Text Client Push

Big text client push supports text entry of up to 160 English/Korean characters.

Additionally, the HTML form available for Android apps is supported (bold, underline, font color).

Push messages can be created and displayed through the setBigTextClientPushEvent API.

IgaworksUnityPluginAOS.LiveOps.setBigTextClientPushEvent(
	1, 				// Delay seconds, Seconds before sending
	"contentText", 			// contents
	"bigContentTitle", 		// normal push message
	"Let's play now! WoooooooW!!",	// big text that will be displayed in the push
	"summaryText", 			// summary text that will be displayed in the push
	1, 				// Event ID, needed when canceling	false				// Whether it will be displayed even when the app is running
);

 + Push Display Method

How pushes are displayed may vary according to its type, Android OS version, and the status of the push message bar.

Check out the link below for more details.



Live Operation: Additional Options


User Targeting

You can create a user group manually to move it to push targets.

Created user groups can be verified in the Live Operation Admin page. They are not available in the client push.

Set your user group by using the setTargetingData API. See below for parameters and examples.

  • user_group : The name of user group available at the management page.
  • data : Object type user data that will be input in user group. Supports bool, int, long, float, String.
//IgaworksUnityPluginAOS.LiveOps.setTargetingData(String user_group, Object user_data);
//user_group : Name of the user group which can be checked in the admin page.
//user_data : User data to register to the user group, We support int, long, double, bool, object in user_data.
//e.g.) You can register the data of purchases to the group which the purchased users were grouped into.
IgaworksUnityPluginAOS.LiveOps.setTargetingData("purchaseCount", 10);

Sync Targeting Data
Call resume api to sync the targeting data to the Live Operation Server.
Add the following in Activity OnApplicationPause().
void OnApplicationPause(bool pauseStatus){
	if (pauseStatus){
		Debug.Log("go to Background");
		IgaworksUnityPluginAOS.Common.endSession();
	}
	else{
		Debug.Log("go to Foreground");
		IgaworksUnityPluginAOS.Common.startSession();
		IgaworksUnityPluginAOS.LiveOps.resume();
	}
}

Manual Sync

To update the data sync manually, call flushTargetingData api to sync the targeting data to the Live Operation Server.
IgaworksUnityPluginAOS.LiveOps.flushTargetingData ();


Enable/Disable Push

Can set whether to receive push message or not. And it calls API as it's configured.
Furthermore, we offer delegate for this event. Use the delegate to process the result of the action.


Set Push

enableService API is called, and this is the example including the parameter.
  • true : Receive Push.
  • false : Does not receive Push.
//true:Receive Push, false:Does not receive push
IgaworksUnityPluginAOS.LiveOps.enableService (false);

델리게이트 이용(depreciated v1.3.2)

전송되는 푸시에 대해서 수신 여부 이벤트 대한 델리게이트를 제공합니다.
enableServiceWithDelegate API를 호출하여 사용하며, 파라미터와 사용 예시는 다음과 같습니다.
void Start () {
	//true:수신모드, false:수신거부모드
	IgaworksUnityPluginAOS.LiveOps.enableServiceWithDelegate (true);

	IgaworksUnityPluginAOS.OnEnableService = mOnEnableService;
}

void mOnEnableService(bool isSuccess){
	Debug.Log("OnEnableService :::: " +  isSuccess);
} 


Replacing the Push Icon Image

The image the Target Push use as the push icon is the app icon image registered as the Launcher Icon.
If you need to change the image for the Google Featured, you can replace the image by calling setNotificationIconStyle api.
//IgaworksUnityPluginAOS.LiveOps.setNotificationIconStyle(string smallIcon, string largeIcon, string iconbackground_argb);
IgaworksUnityPluginAOS.LiveOps.setNotificationIconStyle ("ic_small_filename", "ic_large_filename", "ff9d261c");

// IgawLiveOps_v1.2.9_thirdparty 이전 버전 API
  IgaworksUnityPluginAOS.LiveOps.setNotificationIconName("IconFileName");
+ Call after IgaworksUnityPluginAOS.LiveOps.initialize api.
+ Input the image filename without the extension.
+ Every image that is suitable for the Drawable folder with every resolution must be added.


Notification Settings

Heads-up notifications and Lockscreen notifications settings are provided in Android os 5.0 or above.

Heads-up notification feature allows you to send push notifications to an active device. Lockscreen notification feature lets you to send push notifications on the lockscreen.

(See link for more information. [Google Page for Developers])

Call setNotificationOption api to set Heads-up/Lockscreen notifications.

Heads-up notifications Settings (priority)

  • PRIORITY_MAX (int:2), Heads-up notifications ON
  • PRIORITY_HIGH (int:1), Heads-up notifications ON
  • PRIORITY_DEFAULT (int:0), Heads-up notifications OFF
  • PRIORITY_LOW (int:-1), Heads-up notifications OFF
  • PRIORITY_MIN (int:-2), Heads-up notifications OFF

Lockscreen notifications Settings (visibility)

  • VISIBILITY_SECRET (int:-1), Lockscreen notifications OFF
  • VISIBILITY_PRIVATE (int:0), Lockscreen notifications ON, with no preview shown
  •  VISIBILITY_PUBLIC (int:1), Lockscreen notifications ON, with previews shown.
// void setNotificationOption(int priority, int visibility)
IgaworksUnityPluginAOS.LiveOps.setNotificationOption(IgaworksUnityPluginAOS.AndroidNotificationPriority.PRIORITY_HIGH, IgaworksUnityPluginAOS.AndroidNotificationVisibility.VISIBILITY_PUBLIC);
+ Lockscreen notifications will be activated when user's device is on the "Hide sensitive content" mode.
+ Lockscreen notifications might not work when using a lockscreen.


Stacking Notifications (InboxStyle)

You can group all the notifications together in a stack. Inbox Style works only in the server push.
(*Inbox Style is not supported in the client push, in which the push ID is not identified.)

Call setStackingNotificationOption api to set stacking notifications.

Stacking Notifications Settings (useStacking)

  • true : Stacking notifications ON.
  • false : Stacking notifications OFF.

Stacking Title Settings (useTitleForStacking)

  • true : When expanding the notifications, show the title.
  • false : When expanding the notifications, show the text.

Title and Text Settings (ContentTitle, ContentText)

  • empty :  Show the most recent title and text.
  • your_custom_message : Show the title and text called by the api.

Expanded Notifications Title Settings (bigContentTitle)

  • empty : Show ContentTitle.
  • your_custom_message : Show the title called by the api.

Expanded Notifications Text Settings (bigContentSummaryText)

  • empty : Do not use the content summary.
  • your_custom_message : Show the content called by the api.
//void setStackingNotificationOption(bool useStacking, bool useTitleForStacking, string ContentTitle, string ContentText, string bigContentTitle, string bigContentSummaryText)
IgaworksUnityPluginAOS.LiveOps.setStackingNotificationOption(true, false, "More events are waiting for you", "See detail", "All events", "For Summary Text");