로딩중입니다
Live Operation: Target Push Integration: Unity iOS
6/20/2016 4:52:07 PM

Live Operation Service

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

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

[Live Operation Guide]


Notice
  1. IGAW General Integration must be set in order to integrate Live Operation add-on.  [IGAW General Integration: Unity iOS]
  2. In order to integrate Live Operation, IgaworksUnityPlugin_iOS~*.unitypackage file must be included in Unity project.  [SDK Installation: Unity]



General Setting

These settings are required to use Live Operation service.


Upload APNS certificate

APNS certificate created at Apple Developer Center has to be uploaded to the Live Operation Management page.

+ For develop version, upload Development version, and upload .p12 type Production certificate for App Store version.


Edit Info.plist

If iOS SDK Target is 7.0 or above, Add the node below on Info.plist.



Live Operation API

To use the Live Operation service, edit UnityAppController.mm file in the Classes group of Xcode to integrate.

Live Operation supports Server Push and Client Push.

Server Push sends push message listed on the Live Operation management page, and Client Push uses API to create push within the client.



Basic Integration / Server Push

Server Push is availabe with the general integration.


Input User ID

User ID 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(e-mail, name, phone number, username).
  3. Must go through URL encoding if contains Korean, special Character, or blank space.
  4. Must be set before LiveOpsInitPush API is called.

Follow the above notice when input the User ID value.

IgaworksCorePluginIOS.SetUserId("player1001");


Call Initialize API

  1. SetUserId
  2. LiveOpsInitPush
  3. setDeviceToken : Register to UntiyAppController.mm file of the Xcode.
// Unity Project
public class MySampleScene : MonoBehavior {
 
    void Start () {
        //Input User ID.
	IgaworksCorePluginIOS.SetUserId("player1001");

        //Initialize Live Operation.
	LiveOpsPluginIOS.LiveOpsInitPush();
    }       
}
// Xcode Project
#include <IgaworksAD/LiveOps.h>

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
 AppController_SendNotificationWithArg(kUnityDidRegisterForRemoteNotificationsWithDeviceToken, deviceToken);
 UnitySendDeviceToken(deviceToken);
 //Set Device Token
 [LiveOpsPush setDeviceToken:deviceToken];
}

SetUserId, LiveOpsInitPush api should be called from Unity Project.

+ setDeviceToken api should be called from UnityAppController.mm file, after building it from Unity Project to Xcode.


Add Handler

Add Handler to manage Server Push and Local Push message.

Add Handler by importing the LiveOps.h from the UnityAppController.mm file in the Classes group of Xcode, after building it from Unity Xcode.


//add LiveOps header
#include <IgaworksAD/LiveOps.h>

- (void)application:(UIApplication*)application didReceiveNotification:(UILocalNotification*)notification
{
 AppController_SendNotificationWithArg(kUnityDidReceiveLocalNotification, notification);
 UnitySendLocalNotification(notification);
 [LiveOpsPush handleLocalNotification:notification];
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0
#warning “Remote push open tracking is counted only when user touched notification center under iOS SDK 7.0”

// iOS version below 7,
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
 AppController_SendNotificationWithArg(kUnityDidReceiveRemoteNotification, userInfo);
 UnitySendRemoteNotification(userInfo);
 [LiveOpsPush handleRemoteNotification:userInfo fetchHandler:nil];
}
#else
// iOS version 7 and above,
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo fetchCompletionHandler:(void
(^)(UIBackgroundFetchResult))completionHandler
{
 AppController_SendNotificationWithArg(kUnityDidReceiveRemoteNotification, userInfo);
 UnitySendRemoteNotification(userInfo);
 [LiveOpsPush handleRemoteNotification:userInfo fetchHandler:completionHandler];
}
#endif

+ Handler's standard is iOS 7 just like the code above and it needs to be added separately for each iOS version.

 


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 a Web URL(http://~) type, App Scheme URL(myApp://deepLinkAction) type, or Json({“url”:”deepLinkAction”}) type.


Edit Info.plist

Add a node in Info.plist to use deep link feature.



Deep Link Data Verification

To verify the received deep link data, you can use either Live Operation Listener or AppDelegate.

If you use Json type deep link, Live Operation is the only option.

  • Live Operation Listener
  • AppDelegate


Use Live Operation Listener

To use the listener, you have to add it before handleAllNotificationFromLaunch: API.

You can see deep link info at pushInfos and specified information is:

    1. pushInfos.sentTime : Sent Time
    2. pushInfos.bodyText : Push Message
    3. pushInfos.deepLinkUrl : Apple Scheme Url type deep link, default -> nil
    4. pushInfos.deepLink : Json type deep link, default -> nil
-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
	// Register the listener for deep link
	[LiveOpsPush setRemoteNotificationListener:^(NSArray* pushInfos, BOOL isForeGround) {
		for(LiveOpsPushInfo *pushInfo in pushInfos){
			/* pushInfos object */
			// pushInfo.sentTime : Sent time
			// pushInfo.bodyText : Push message
			// pushInfo.deepLinkUrl : deep link URL, default-nil 
			// pushInfo.deepLink : deep link JsonObject, default-nil
			
			/* isForeGround */
			// YES : Receive push when the app is enabled
			// NO : Receive push when app is not enabled
		}       
	}];
	
	//Register LiveOps Push Notification Handler.
	[LiveOpsPush handleAllNotificationFromLaunch:launchOptions];
	
   return YES;
}


Use AppDelegate 

If you use Apple Scheme Url type deep link, you can read deep-link information using AppDelegate.

Do this by receiving information from url parameter at application: openUrl: sourceApplication: annotation: delegate.

#import "AppDelegate.h"
#import <IgaworksAD/IgaworksAD.h>
#import <IgaworksAD/LiveOps.h>
 
@implementation AppDelegate
 
-(BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(idD)annotation
{
    //This is where the push deep link will be transferred to.
    //Use the checked deep link data to perform the wanted action.
    NSLog(@"LiveOps Deep Link Url Info : %@", [url absoluteString]);
 
    //ex. When the deep link was received to liveOps://com.igaworks.test?view=myview&param=1
    NSString* query = [url query];
    NSArray *queryPairs = [query componentsSeparatedByString:@"&"];
    NSMutableDictionary *pairs = [NSMutableDictionary dictionary];
    for(NSString* queryPair in queryPairs)
    {
        NSArray *bits = [queryPairs componentsSeparatedByString:@"="];
        NSString *key = [bits objectAtIndex:0];
        NSString *value = [bits objectAtIndex:1];
        [pairs setObject:value forKey:key];
    
        NSLog(@"LiveOps Deep Link Action~!! key: %@ , value: %@" , key, value);
    }
    return YES;
}

+ Json type deep link is unavailable for AppDelegate.



Local Push (Client Push)

Live Operation uses API within the client in order to offer client push feature.
When the required settings are satisfied, push message is created and exposed.
Furthermore, if it can communicate with a developer's server, it can catch server event to create push message.


Create and Expose

Use the API below to create and expose push message.
[LiveOpsPush registerLocalPushNotification:localPid  //Unique identifier
                                      date:dateObj   //Date
                                      body:@"hello"  //Message that will be displayed in the local push에
                                    button:@"go":     //local push confirm button or unlock button text
                                 soundName:nil       //Name of the sound file to execute, nil : play iOS default sound
                               badgeNumber:0         //The number on the unread messages that will be displayed on the app icon when unread
                                  customPayload:nil  //User information registered through customPayload
];    

Cancel

Use cancelLocalPush: API to cancel any local push.

[LiveOpsPush cancelLocalPush:localPid]; //localPid : The push id entered when registered the local push



Live Operation : Additional Options


User Targeting

You can create a user group manually to move it to push targets.
You can manually set the data for creating user groups.

Set Targeting Data

You can set customized user data to send target push.
Created custom user data is listed at Target Push managemet page. This example shows grabbing user's age as the custom data.
//LiveOpsSetTargetingNumberData(int customUserData, string customUserDataKey);
//LiveOpsSetTargetingStringData(string customUserData, string customUserDataKey);

LiveOpsPluginIOS.LiveOpsSetTargetingNumberData(86, "age");
customUserData : Input user data for targeting. 
customUserDataKey : Set user custom data key.

Enable/Disable Push

Set whether to receive push message or not. Generally 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

LiveOpsSetRemotePushEnable API is called and these are the examples for the parameter:
  • true : Receive Push.
  • false : Does not receive Push.
LiveOpsPluginIOS.LiveOpsSetRemotePushEnable(false);