💡
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

Register to topics

Once you have a notification token you can register this device to push notifications and register to topics:

MPush.onToken = (token) async {
  print("Token received $token");
  await MPush.registerDevice(token).catchError(
    (error) => print(error),
  );
  await MPush.registerToTopic(MPTopic(code: 'Topic')).catchError(
    (error) => print(error),
  );
  print('Registered');
};

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.

PreviousRequest a tokenNextLaunch notification

Last updated 4 years ago

Was this helpful?

🔷