Register to topics
Once you have a notification token you can register this device to push notifications and register to topics:
1
MPush.onToken = (token) async {
2
print("Token received $token");
3
await MPush.registerDevice(token).catchError(
4
(error) => print(error),
5
);
6
await MPush.registerToTopic(MPTopic(code: 'Topic')).catchError(
7
(error) => print(error),
8
);
9
print('Registered');
10
};
Copied!
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.
Last modified 11mo ago
Copy link