Node v6
Starting with v0.19 Astro must be used with Node v6+!
Menu

Mobify Push Setup

An Astro developer needs to configure their app to work with Mobify Push. The developer needs to obtain two pieces of information to interact with the Mobify Connection Center:

After these two pieces of information are obtained an EngagementController and PushPlugin can be initialized in app.js in order to enable push in the app.

const mobifyProjectId = 'your_mobify_project_id'
const pushSiteId = 'your_push_site_id'

const engagementControllerPromise = EngagementController.init(mobifySlugName)

const pushPlugin = await PushPlugin.init(pushSiteId, engagementControllerPromise)
if (Astro.isRunningInAndroidApp()) {
    const notificationIconPath = 'file:///your_web_push_notification_icon.png'
    pushPlugin.setNotificationIconPath(notificationIconPath)
}

iOS Setup

This setup assumes you already have an app and an App ID in the Apple Developer Portal.

Enabling the Push Notification Service

To enable the push notification service:

For complete Mobify Push integration, we'll need to enable the Associated Domains entitlement as well, and list applinks:deeplink.mobify.net for Connection Center test push support.

Creating Push Notification Certificates

To create and upload a push notification certificate, follow the Mobify Push documentation. Once you have followed these instructions, contact Mobify Customer Support to upload your PEM file.

Setting up Universal Links

On iOS 9 and later, you can support Universal Links. Universal links are required so that you can automatically register for test push notifications. The Astro Push Plugin routes incoming push message URLs through the normal universal links logic. To set up universal links view the Mobify deeplinking documentation and the Apple documentation.

Creating a Push Provisioning Profile

Once you have enabled Push Notifications, you need to regenerate and re-download the provisioning profile for your app, which will now be enabled for push notifications.

Testing Device Registration

If you'd like to test that your device has successfully registered for push notifications you can send a test push notification using houston. Your device token can be found by implementing application:didRegisterForRemoteNotificationsWithDeviceToken: of UIApplicationDelegate.

Making Ad-Hoc builds

In order to test Mobify Push, an app must be running in the production environment for push notifications. Unfortunately, the only ways to enable this are to test on a released app, or to test using an ad-hoc provisioning profile.

So if a developer wants to test Mobify Push, they will need to force Xcode to use the ad-hoc provisioning profile, and also disable the automatic debugger attaching.

The unfortunate side-effect is that you cannot attach a debugger when the app is built this way.

You can find more information about Ad Hoc deployments in Apple's App Distribution Guide.

Android Setup

The Android app needs to be configured with a notification icon that will be displayed in the notification area and as the main icon of the notification itself.

To configure the push plugin with a notification icon, see setNotificationIconPath().

These icons should be flat (no gradients), white and face-on perspective.

The icon content should be 20dp x 20dp and should have 4dp of empty space bordering the content. The full icon should be 24dp x 24dp.

Usage

For the full documentation on how to use Mobify Push notifications, please refer to the push API Reference.

Subscribing to Push Notifications

Subscribing to a push notification is done via the subscribe function.

Setting up a test push event

To subscribe for test Mobify Push notifications, call subscribeTest(). If you would like to subscribe to test push automatically, you can follow the Enable New Test App link in Mobify's Connection Center from a phone with your app installed. Subscribing to test push notifications can take a few minutes, and requires an internet connection.

If registration fails, Astro will continue to try to register you for push notifications while the app is running.

Responding to push when the app is open (iOS Only)

If the app is open when the user receives the notification, the event messageReceivedWhenAppIsOpen will be triggered.

Read more about Mobify Push in the Push documentation.

Finally, when sending push notifications, it's usually a good idea to follow the specific platform's guidelines: