💡
MPush
  • 💡MPush Documentation 💡
  • 🔑 API
    • Introduction
    • Authentication
    • Send Notifications
    • Topics
  • 🍏 iOS SDK
    • Introduction
    • Installation
    • Add Push Notification to your app
    • Integrate MPush
    • Rich Notifications
  • 📱 Android SDK
    • Introduction
    • Setup
    • Register a device
    • Subscribe to topics
  • 🔷Flutter SDK
    • Introduction
    • Installation
    • Android Setup
    • iOS Setup
      • Rich Notifications
      • Custom replacements
    • Flutter Setup
    • Request a token
    • Register to topics
    • Launch notification
Powered by GitBook
On this page

Was this helpful?

  1. Flutter SDK

Flutter Setup

The first thing you need to do is to set your apiToken:

MPush.apiToken = 'YOuR_API_TOKEN';

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.

MPush.configure(
  onNotificationArrival: (notification) {
    print("Notification arrived: $notification");
  },
  onNotificationTap: (notification) {
    print("Notification tapped: $notification");
  },
  androidNotificationsSettings: MPAndroidNotificationsSettings(
    channelId: 'mpush_example',
    channelName: 'MPush Notifications',
    channelDescription: 'Push notification channel', 
    icon: '@mipmap/icon_notif',
  ),
);

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.

PreviousCustom replacementsNextRequest a token

Last updated 4 years ago

Was this helpful?

🔷