Flutter Setup
The first thing you need to do is to set your apiToken:
1
MPush.apiToken = 'YOuR_API_TOKEN';
Copied!
Then you need to configure MPush with the callbacks that will be called when a notifcation arrives or is tapped and the android notification settings.
1
MPush.configure(
2
onNotificationArrival: (notification) {
3
print("Notification arrived: $notification");
4
},
5
onNotificationTap: (notification) {
6
print("Notification tapped: $notification");
7
},
8
androidNotificationsSettings: MPAndroidNotificationsSettings(
9
channelId: 'mpush_example',
10
channelName: 'MPush Notifications',
11
channelDescription: 'Push notification channel',
12
icon: '@mipmap/icon_notif',
13
),
14
);
Copied!
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.
Last modified 1yr ago
Copy link