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.
You will need the following:
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.
Here is where you can create placeholders for your mobile apps, along with necessary push certificates and payload information. Let's create an app:
Now that an app placeholder has been created, you can add custom notification payloads that can integrate directly with your mobile app.
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
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
Once this information is saved in our system, you can view users in Notification Center and target push notifications to them.
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.
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.