PushServiceHandler class
Handler de notificações recebidas.
O pacote não depende diretamente do firebase_messaging para manter a instalação leve. Integra-se assim:
final handler = PushServiceHandler();
handler.onOpened = (notification) {
// navegar para o ecrã certo
};
// No main(), antes de runApp:
FirebaseMessaging.onMessage.listen((message) {
handler.notifyReceived(PushNotification.fromMap(message.data));
});
FirebaseMessaging.onMessageOpenedApp.listen((message) {
handler.notifyOpened(PushNotification.fromMap(message.data));
});
FirebaseMessaging.instance.getInitialMessage().then((message) {
if (message != null) handler.notifyOpened(PushNotification.fromMap(message.data));
});
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- onOpened ↔ OnPushOpened?
-
getter/setter pair
- onReceived ↔ OnPushOpened?
-
getter/setter pair
- onTokenRefreshed ↔ OnTokenRefreshed?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyOpened(
PushNotification notification) → void -
notifyReceived(
PushNotification notification) → void -
notifyTokenRefreshed(
String token) → void -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited