Notification Center for Mobile

Notification Center adds the ability to track the location of your mobile users, and automatically send push notifications based on their location. It is a great way to send a call to action and ask for content for a particular event or theme. This article goes through the steps involved to setup your app to work with Notification Center.

Prerequisites

You will need the following:

  1. New Spark Platform APIs
  2. Access to Notification Center
  3. An iOS App and a developer
  4. If you are using Single Sign On, see this doc on how to set this up.

Step 1 - Mobile App Placeholder Creation

The first step is to create the concept of a mobile app in New Spark Platform. You can create a single app, or multiple apps in your project.

  • Navigate to Notification Center in New Spark Platform
  • Click on Mobile Payload Configuration

Here is where you can create placeholders for your mobile apps, along with necessary push certificates and payload information. Let's create an app:

  • Click New and enter the following fields:
  • Mobile App Name - A friendly name for your app
  • App Code: - A unique identifier that will be applied to all users who are a part of this app. This allows you to target your users between multiple apps in your project, and should not be changed once live
  • Apple APNS Key: If you have an iOS app, this is the contents of the .pem file from the APNS Certificate that is used to send iOS push notifications

Step 2 - Notification Payloads

Now that an app placeholder has been created, you can add custom notification payloads that can integrate directly with your mobile app.


  • Click the add button to add a new payload for the selected app, and enter the following fields:
  • Payload Name - The friendly name of the payload in order to differentiate between the different types of notifications you want to create for this app. This name is used as a label in the list of available payloads to be sent when a notification is scheduled
  • iOS Payload - The contents of the payload to be sent for iOS Apps. Learn more here.

Basic iOS Payload Example:

{
    "aps": { "alert": "{$notification.message}", "sound": "default" }
}

Note that the variable {$notification.message} is required as the main body of the alert

 

Step 3 - API Integration in Mobile Apps

To track the location of users in your app during runtime and while in the background, use your preferred native app method. Then all you need to do is update the necessary user information to New Spark Platform using APIs.

See here for detailed documentation on the updateUserInfo API call. Below is a simplified example:

http://api.filemobile.fm/services/rest/users/updateUserInfo?APIKEY=[APIKEY]&id=USER_ID&newProperties[deviceinfo][DEVICE_TOKEN][appcode]=APPCODE_NAME&newProperties[deviceinfo][DEVICE_TOKEN][latitude]=USER_LATITUDE_LOCATION&newProperties[deviceinfo][DEVICE_TOKEN][longitude]=USER_LATITUDE_LOCATION&newProperties[deviceinfo][DEVICE_TOKEN][assignmentnotification]=1_OR_0&vhost=VHOST_ID
  • USER_ID - The ID of the user to update
  • DEVICE_TOKEN - Unique token of the user's device. Learn more about how to retrieve this.
  • APPCODE_NAME - Unique appcode name of the mobile app that you want to target the user with
  • USER_LATITUDE_LOCATION - Latitude coordinate of the user from their geo-location
  • USER_LATITUDE_LOCATION - Longitude coordinate of the user from their geo-location
  • 1_OR_0 - 1 or 0. The value of the user to opt IN or OUT of push notification assignments
  • VHOST_ID - The ID of the vhost that you are using

Once this information is saved in our system, you can view users in Notification Center and target push notifications to them.

Step 4 - Logging Into and Out of the App

When a user logs out of the mobile app, they should not receive push notifications. To do this, simply update the user information with the following so that they are no longer associated with the app.

http://api.filemobile.fm/services/rest/users/updateUserInfo?APIKEY=[APIKEY]&id=[USER_ID]&newProperties[deviceinfo][DEVICE_TOKEN][appcode]=loggedout&vhost=[VHOST_ID]

appcode = loggedout will remove the user from the targetted app, thereby preventing them from receiving push notifications in a logged out state.

When the user logs back in, simply update all of their user info again, including the correct value for appcode.

Step 5 - Using Notification Center

The setup is now complete, and you can start to use Notification Center to target your users and schedule push notifications. Please see this separate article for the walkthrough.

0 comments

Be the first to comment on Notification Center for Mobile.

Add a Comment

  • captcha