Push notifications
Last updated
Was this helpful?
Last updated
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 MBMessages
instead of MPush
you have to do the following changes:
Set the push token like this:
Configure the callbacks and Android native interface like this:
To configure the Android part you need to pass a MPAndroidNotificationsSettings
to the configure sections, it has 2 parameters:
channelId
: the id of the channel
channelName
: the name for the channel
channelDescription
: the description for the channel
icon
: the default icon for the notification, in the example application the icon is in the res folder as a mipmap, so it's adressed as @mipmap/icon_notif
, iff the icon is a drawable use @drawable/icon_notif
.
To request a notification token you need to do the following things:
Set a callback that will be called once the token is received correctly from APNS/FCM
Request the token using MPush:
Once you have a notification token you can register this device to push notifications and register to topics:
The topic are instances of the MPTopic
class which has 3 properties:
code
: the id of the topic
[Optional] title
: the readable title of the topic that will be displayed in the dashboard, if this is not set it will be equal to code
.
[Optional] single
: if this topic represents a single device or a group of devices, by default false
.
MBurger has 2 default topics that you should use in order to guarantee the correct functionality 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
If the application was launched from a notification you can retrieve the data of the notification like this, this will be null
if the application was launched normally: