The variables in the Message class:
Variable | Description |
---|---|
messageContent | Message |
URL | An optional URL |
params | Custom parameters |
pushType | Push Type |
altURL | Alternate URL |
mediaUrl | Image and Video content URL |
cId | Campaign id |
sound | Sound name |
Apple Push Notification Server (APNS) is a central server where all the IOS devices are connected any 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 with the related message.
Related Marketing Cloud expects the following information for APNS communication from you:
APNS works in two modes, Sandbox and Production.
Sand box 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 related files, you can integrate SDK to your project using the following steps:
For registering the application into APNS system, the following method should be used:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
For IOS 8 and later, the following code should be used:
[[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:
- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { NSLog(@"didRegisterForRemoteNotificationsWithDeviceToken"); [[EuroManager sharedManager:@"AppcentIOSTest1"] registerToken:deviceToken]; }
In the APPLICATION: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 system in order to sent messages. In the example, APPCENTIOSTEST1 value is a code value that is given by EuroMsg for your application.
If device takes an error during recording, the following metod informs you the type of error:
- (void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { NSLog(@"Registration failed : %@",error.description); }
EuroManager instance is activated as below:
EuroManager *euroInstance = [EuroManager sharedManager:@"AppcentIOSTest1"]; [euroInstance setDebug:YES];
If the additional parameters of the user are known, they can be added as follows;
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 server, you should call synchronize method.
[[EuroManager sharedManager:@"AppcentIOSTest1"] synchronize];
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { NSLog(@"didReceiveRemoteNotification : %@",userInfo); [[EuroManager sharedManager:@"AppcentIOSTest1"] handlePush:userInfo]; }
If you use a IOS 8 or later, the following method should be called.
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { NSLog(@"didReceiveRemoteNotification:fetchCompletionHandler : %@",userInfo); [[EuroManager sharedManager:@"AppcentIOSTest1"] handlePush:userInfo completionHandler:completionHandler]; }
- (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]; }
- (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 in the Message class:
Variable | Description |
---|---|
messageContent | Message |
URL | An optional URL |
params | Custom parameters |
pushType | Push Type |
altURL | Alternate URL |
mediaUrl | Image and Video content URL |
cId | Campaign id |
sound | Sound name |