Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

General Information

Apple Push Notification Server (APNS) is a central server where all the IOS iOS devices are connected at any given time. If you wish to send a push message to an application, then this message is sent to APNS and APNS forwards this message to the related device. In order to send the message to the target device and application, a token is generated for each device-application pair and this token is sent to APNS together along with the related message.


 

Related Marketing Cloud expects You need to send the following information to RMC for APNS communication from you:

APNS Methods

APNS works in two modes, Sandbox and Production.:Sand box

  • Sandbox certificate is used for applications that are not submitted to the Appstore and generally when the app is attached to the debugger

...

  • (USB cable connection to XCode).
  • Production certificate is used for applications distributed through

...

  • ad-hoc and Testflight (closed distribution) and for applications in the

...

  • appstore.

After you imported the SDK into your project by adding the related files, you can integrate the SDK to your project using the following steps:For .


The following method should be used for registering the application into the APNS system, the following method should be used:


Code Block
languageapplescript
linenumberstrue
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
        (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];


For IOS 8 and later, the The following code should be used for iOS 8 and later versions:


Code Block
languageapplescript
linenumberstrue
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

 

After that point, the user has to accept to receive push messages. If the user accepts and the device is successfully registered to the APNS, the following method is called in AppDelegate:

 

Code Block
languageapplescript
linenumberstrue
- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
   
    NSLog(@"didRegisterForRemoteNotificationsWithDeviceToken");
   
    [[EuroManager sharedManager:@"AppcentIOSTest1"] registerToken:deviceToken];
}

 

In the 

Status
subtletrue
colourRed
titleapplication:didRegisterForRemoteNotificationsWithDeviceToken:
 method, deviceToken variable is the generated token by APNS. After receiving this token, registerToken method is called in EuroManager. This token value must be recorded to the EuroMessage RMC system in order to sent send messages. In the example, 
Status
subtletrue
colourRed
titleAppcentIOSTest1
 value is a code value that is given by EuroMsg RMC for your application.

 

If device takes an error during recording, the The following metod method informs you the type of error If the device takes an error during recording:

 

Code Block
languageapplescript
linenumberstrue
- (void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    NSLog(@"Registration failed : %@",error.description);
}

 

EuroManager instance is activated as shown below:

 

Code Block
languageapplescript
linenumberstrue
 EuroManager *euroInstance = [EuroManager sharedManager:@"AppcentIOSTest1"];
    [euroInstance setDebug:YES];

 

If the additional parameters of the user are known, they can be added as follows;shown below:

 

Code Block
languageapplescript
linenumberstrue
euroInstance.userEmail = @"uysalmo@gmail.com";

    [euroInstance setTwitterId:@"com90"];
    [euroInstance setFacebookId:@"com90"];
    [euroInstance setUserLatitude:41.11 andLongitude:29.12];
    [euroInstance setAppVersion:@"1.0"];
   
    [euroInstance setUserKey:@"ozanUysalKey"];

 

In any step, if you add a new parameter and want to send it to EuroMsg the RMC server, you should call synchronize the synchronize method.:

 

Code Block
languageapplescript
linenumberstrue
    [[EuroManager sharedManager:@"AppcentIOSTest1"] synchronize];


If a push notification arrives, application:didReceiveRemoteNotification method is invoked. The incoming message content should be given to the handlePush method in the EuroManager instance.

Code Block
languageapplescript
linenumberstrue
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
   
    NSLog(@"didReceiveRemoteNotification : %@",userInfo);
   
    [[EuroManager sharedManager:@"AppcentIOSTest1"] handlePush:userInfo];
    
}

 

If you use a IOS are using iOS 8 or later version, the following method should be called.

Code Block
languageapplescript
linenumberstrue
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { NSLog(@"didReceiveRemoteNotification

:

fetchCompletionHandler : %@",userInfo); [[EuroManager sharedManager:@"AppcentIOSTest1"] handlePush:userInfo completionHandler:completionHandler]; }If you use Visilabs in your application and wish to report the push messages to Visilabs, you can use reportVisilabs: method. reportVisilabs: method expects an URL produced by Visilabs SDK and is used as below:

 

Code Block
languageapplescript
linenumberstrue
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
   
    NSLog(@"didReceiveRemoteNotification:fetchCompletionHandler : %@",userInfo);
   
    Visilabs *visi = [Visilabs ...]
    NSString *pushUrl = [visi getPushURL:@"src" withCampaign:@"cam" withMedium:@"med" withContent:@"con"];
   
    [[EuroManager sharedManager:@"AppcentIOSTest1"] reportVisilabs:pushUrl];

    [[EuroManager sharedManager:@"AppcentIOSTest1"] handlePush:userInfo completionHandler:completionHandler];
   
}


When an interactive push is sent, the information of which button is clicked by the user should be transmitted to

EuroMsg side

RMC. For this application: 

Status
subtletrue
colourRed
titlehandleActionWithIdentifier:forRemoteNotification:completionHandler:
 method in the 
Status
subtletrue
colourRed
titleAppDelegate

 is

 is called as shown below:


Code Block
languageapplescript
linenumberstrue
- (void) application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler {
   
    NSLog(@"push clicked : %@ %@",userInfo,identifier);
   
    [[EuroManager sharedManager:@"AppcentIOSTest1"] handleInteractiveAction:identifier userInfo:userInfo];
   
    if(completionHandler != nil) {
        completionHandler(UIBackgroundFetchResultNewData);
    }
}
The variables


 

Variables in the Message class:

 

VariableDescription
messageContentMessage
URLAn optional URL
paramsCustom parameters
pushTypePush Type
altURLAlternate URL
mediaUrlImage and Video content URL
cIdCampaign id
soundSound name

RMC Personalization (visilabs)


If you are using the RMC Personalization (visilabs) module in your application and wish to report the push messages, you can use the reportVisilabs method.

reportVisilabs method expects an URL produced by RMC Personalization (visilabs) SDK and is used as shown below:

Code Block
languageapplescript
linenumberstrue
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
   
    NSLog(@"didReceiveRemoteNotification:fetchCompletionHandler : %@",userInfo);
   
    Visilabs *visi = [Visilabs ...]
    NSString *pushUrl = [visi getPushURL:@"src" withCampaign:@"cam" withMedium:@"med" withContent:@"con"];
   
    [[EuroManager sharedManager:@"AppcentIOSTest1"] reportVisilabs:pushUrl];

    [[EuroManager sharedManager:@"AppcentIOSTest1"] handlePush:userInfo completionHandler:completionHandler];
   
}