MBurger Engagement Platform
User GuideHeadless CMSEngagement Platform
  • 🍔MBurger Engagement Platform 🍔
  • 🍏 iOS Docs
    • Messages
      • Installation
      • Initialization
      • Push notifications
        • Rich Notifications
      • Stylize in app messages
      • Message Metrics
    • Audience
      • Installation
      • Initialization
      • Tracked data
      • Tags
      • Identify a user
      • Location
    • Automation
      • Installation
      • Initialization
      • Triggers
      • Send events
      • View Tracking
  • 📱Android Docs
    • Messages
      • Prerequisites for Push Notifications
      • Installation
      • Initialization
      • Stylization and parameters
      • Push notifications
      • Message Metrics
    • Audience
      • Installation
      • Initialization
      • Tracked data
      • Tags
      • Custom Id
      • Mobile User Id
      • Location Data
    • Automation
      • Installation
      • Initialization
      • Triggers
      • Add events
      • View Tracking
      • Stop/Pause tracking
  • 🔷Flutter Docs
    • Messages
      • Installation
      • Initialization
      • Stylize in app messages
      • Push notifications
        • Rich Notifications
      • Message Metrics
    • Audience
      • Installation
      • Initialization
      • Tracked data
      • Tags
      • Custom Id
      • Mobile User Id
      • Location Data
    • Automation
      • Installation
      • Initialization
      • Triggers
      • Send events
      • View Tracking
Powered by GitBook
On this page

Was this helpful?

  1. iOS Docs
  2. Messages

Push notifications

PreviousInitializationNextRich Notifications

Last updated 4 years ago

Was this helpful?

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 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:

MBMessages.userDidInteractWithNotificationBlock = { payload in
    // Do actions in response
    print("Notification arrived:\n\(payload)")
}

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.

func userNotificationCenter(_ center: UNUserNotificationCenter,
                            willPresent notification: UNNotification,
                            withCompletionHandler
    completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    // Add this line
    MBMessages.userNotificationCenter(willPresent: notification)
    completionHandler(UNNotificationPresentationOptions.alert)
}

func userNotificationCenter(_ center: UNUserNotificationCenter,
                            didReceive response: UNNotificationResponse,
                            withCompletionHandler
    completionHandler: @escaping () -> Void) {
    // Add this line
    MBMessages.userNotificationCenter(didReceive: response)
    completionHandler()
}

🍏
MPush documentation