Push Notification

Push messaging allows you to keep your users up-to-date and re-engage them with your app after periods of inactivity. Upshot.ai makes it simple to send push notifications through Application Push Notification Service(APNS). Upshot.ai also supports pushing an activity along with the Push.

Below are the steps to follow setting up your app for push notifications:

Generate APNS Certificate for iOS Push Notifications
If you already have a push certificate, you can skip these steps.
  1. Login to Apple developer account and click on Certificate, Identifiers and Profiles.
  2. AddFrameworks
  3. On the next screen, select Identifiers > App IDs in the left sidebar and then click on the plus button in the top right corner
  4. AddFrameworks
  5. Enter your app name for the App ID Description section (1). In the App ID Suffix section, select the Explicit App ID option and enter Bundle Identifier(2).
  6. AddFrameworks

    Note: Ensure you have created an App ID without a wildcard(make sure it doesn’t have an asterisk in it). Wildcard IDs cannot use the push notification service

  7. Once you have entered all of the information, scroll down to the bottom of the page and select Continue button. You will now be presented with an overview of your new app ID. Click Register button to continue.

  8. Generate a Certificate Signing Request:
  9. You need to generate a certificate signing request file so that you can use it to request an APNS SSL certificate later on

  10. Select Keychain Access -> Certificate Assistant -> Request a Certificate From a Certificate Authority
  11. AddFrameworks
  12. Enter the required information and check the 'Saved to disk' option. Click Continue and Save
  13. AddFrameworks
  14. Create universal APNS certificate
  15. On the Certificates, IDs & Profiles screen, select Certificates > All in the left sidebar and then click on the plus button in the top right corner:

    AddFrameworks
  16. The Add iOS Certificate screen will appear. Choose Apple Push Notifications service SSL (Sandbox & Production) and click Continue
  17. AddFrameworks
    Here we will create a single universal push certificate which is good for both Development and Production environments
  18. On the next screen choose an App ID you want to create a push certificate for. Then click Continue
  19. AddFrameworks
  20. On the next screen About Creating a Certificate Signing Request (CSR) click Continue
  21. AddFrameworks
  22. Click 'Choose File...' button to locate Certificate Request File that you have saved earlier. Click Generate: and Download
  23. AddFrameworks
  24. Create .p12 file
  25. Still in Keychain Access app, select Certificates option in the bottom section of the left sidebar. You will now need to find the certificate you just made; it will have the name Apple Push Services: < Bundle ID > and paired with a private key

    AddFrameworks
  26. Right-click on this key and select Export "Apple Push Services ..." option. In the popup that appears, you can call the file whatever you want, but make sure that File Format is set to Personal Information Exchange (.p12). When exporting the certificate, you can provide a password for the p12 file.

Upload .p12 certificate to Dashboard

Upload .p12 push certificate to Upshot.ai dashboard under Push Notification Section. Select Push Notification in left menu -> click on push settings.

Upload Sandox Box and Production .p12 certificate and click on save.

AddFrameworks

Registering for Push notification:

After registering for remote notfications didRegisterForRemoteNotificationsWithDeviceToken or didFailToRegisterForRemoteNotificationsWithError callback will be invoked. And pass the token information to Upshot.ai as shown below

Sample Code:
BKUserInfo *userInfo = [[BKUserInfo alloc] init];
BKExternalId *externalId = [[BKExternalId alloc] init]; [externalIdsetApnsID: pushToken];
[userInfosetExternalId:externalId];
[userInfobuildUserInfoWithCompletionBlock:^(BOOL success, NSError * _Nullable error) {

}];
let userInfo = BKUserInfo()
let externalId = BKExternalId()
externalId.apnsID = pushToken
userInfo.externalId = externalId
userInfo.build { (status, error) in
}

Enhance/Rich Notification

iOS 10 brings us push notifications with Rich Media Attachment which includes viewing photos, videos, gifs and audio right there, within the notification.

Having these media attachments as a part of your notification is achieved with the use of the new Notification Service Extension. You can also have richer view controller level content within the media attachment view of the notification using Notification Content Extension.

NOTE:

Upshot.ai supports Rich Media Attachment and Push Notification Templates.

Below are the steps to enable enhance notifications.

Enable App Groups

Select you App Target -> Select Capabilities -> Search for App Groups and do the changes as shown in below.

AddFrameworks
App Group ID Recommendation:

NOTE:

To support Push Notification View count and Templates, it is recommended to have a separate App Group ID set for Upshot.ai with a format group.{app bundle id}.Upshot.And make sure that the same group id is enabled for all the targets(AppTarget, Notification Service Extension, and Notification Content Extension).

Steps to setup Notification Service Extension:
  1. Create a Notification Service Extesion Target:
  2. To create a notification service extension in your project, in Xcode, select File -> New -> Traget -> Choose Notification Service Extension template and activate.

    AddFrameworks

    Set the name of the extension target and the programing language which you want to use.Activate the scheme for Extension when prompted for the same.

  3. Add UserNotifications framework to extension target:
  4. Add UserNotifications framework and Upshot.ai framework to Linked Frameworks and Libraries of notification service extension target as shown below:

    AddFrameworks
  5. Set the App Group ID for Extension:
  6. Enable App Groups in for your notification service extension target and enable the same App group id which was selected for the App Target

    AddFrameworks
  7. Code Level Changes:
  8. AddFrameworks

Steps to setup Notification Content Extension:

  1. Create a Notification Content Extension Target:
  2. To create a notification service extension in your project, in Xcode, select File -> New -> Traget -> Choose Notification Content Extension template and activate.

    AddFrameworks

    Set the name of the extension target and the programing language which you want to use. Activate the scheme for Extension when prompted for the same.

  3. Add UserNotifications and UserNotificationsUI framework to extension target:
  4. Add UserNotifications, UserNotificationsUI framework and Upshot.ai framework to Linked Frameworks and Libraries of notification content extension target as shown below. And set the deployment target to 12.0

    AddFrameworks
  5. Set the App Group ID for Extension:
  6. Set App Groups in your Notification Content Extension target and enable the same App group id which was selected for the App Target

    content_objc
  7. Info.plist Changes:
  8. The changes in the Info.plist of your Notification Content Extension, as shown below, set NSExtensionAttributes as following

    content_objc
  9. StoryBoard Changes:
  10. Select MainInterface.storyboard in your Content extension and remove the default label which is placed there and set the background color of the view to clear color, as shown below.

    content_objc
  11. Code Level Changes:
  12. Caurosel Push Notification click callback

Sample Push Payload

{
"aps" : {
"alert" :{
"body" : "Message",
"title" : "Title"
},
"badge" : 1 ,
"category" : "Upshot_PushTemplate" ,
"mutable-content" : 1 ,
"sound" : "default"
},
"attachment-type" : "inline-image",
"attachment-url" : "https://media.goupshot.com/bk-purpletalk/5d4d3f3f4ce8f387208b4585/si/56af50e0eaea3.jpg" ,
"bgColor" : "#EB0D8A",
"bk" : "8dcc61363c6a456d54c22e01",
"mColor" : "#898F8E",
"tColor" : "#898F8E",
"cType" : 1,
"bk_mdata" : {
"activity" : 0,
"cid" : "5bc6d386841d64a0768b47c4",
"msgId" : "8dcc61363c6a456d54c22e01" }
}

Send Push Click Detailsto Upshot.ai

Upshot.ai provides push notification click reports and ability to send InApp Notifications along with PushNotifcations. To Support this send push click payload to Upshot.ai

When a user taps on the notification based on the app state and OS version below, notification delegates will be invoked. Send UserInfo payload whenever callback is invoked.

  1. didReceiveRemoteNotification: fetchCompletionHandler
  2. userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response:
Sample Code:
[[BrandKinesis sharedInstance] handlePushNotificationWithParams: userInfo withCompletionBlock:nil];
BrandKinesis.sharedInstance().handlePushNotification(withParams: userInfo) { (error) in
}