Push notifications

With this plugin you can also manage the push notification section of MBurger, this is a wrapper around MPush, the underlying platform, so you should refer to the MPush documentation arrow-up-right to understand the concepts and to start the push integration. In order to use MBMessagesSwift instead of MPushSwift you have to do the following changes:

Set the push token like this:

MBMessages.pushToken = "YOUR_PUSH_TOKEN"

And then register your device to topics (all the other function have a similar syntax change):

MBMessages.registerDeviceToPush(deviceToken: deviceToken, success: {
    MBMessages.registerPushMessages(toTopic: MBPTopic("YOUR_TOPIC"))
})

MBurger has 2 default topics that you should use in order to guarantee the correct functtionality of the engagement platform:

  • MBMessages.projectPushTopic: this topic represents all devices registred to push notifications for this project

  • MBMessages.devicePushTopic: this topic represents the current device

MBMessages.registerPushMessages(toTopics:[MBMessages.projectPushTopic,
                                          MBMessages.devicePushTopic,
                                          MBPTopic("OTHER_TOPIC")])

MBPTopic additional parameters

When creating topic you can specify additional parameters:

  • title: a title fot that topic that will be displayed in the dashboard, if not specified it has the same value as the topic id

  • single: If the topic identify a single user or a group of users, defaults to false

User interaction with a push

With MBMessagesSwift you can setup a callback that will be called when the user interacts with a push notification or opens the app from a push. You can setup the code like this, the payload variable will be the payload of the push:

In order to this to function you will have to tell MBMessagesSwift that a notification has arrived so you need to add this in those lines in your UNUserNotificationCenterDelegate class, often the AppDelegate.

Last updated