PushNotification class

Class for handling FirebaseMessaging.

First, monitor notifications with listen. Notifications can be received after this method is executed.

You can subscribe and unsubscribe to topics by clicking subscribe and unsubscribe.

Notifications can be sent using send. (Assuming that a Function for notification has been set in FirebaseFunctions. It is also possible to set up a FunctionsAdapter in functions).

When a notification is retrieved, value is updated and notifyListeners is called.

By monitoring the status with addListener, it is possible to do something when a notification comes in.

Be sure to specify the notification settings androidNotificationChannelTitle and androidNotificationChannelDescription for Android. Matching androidNotificationChannelId will enable Android to receive notifications as well.

FirebaseMessagingを取り扱うためのクラス。

まずlistenで通知の監視を行います。このメソッド実行後から通知の受け取りが可能になります。

subscribeunsubscribeでトピックの購読、購読解除が行なえます。

sendで通知の送信が可能です。(FirebaseFunctionsで通知用のFunctionが設定されていること前提。functionsFunctionsAdapterを設定することも可能です。)

通知を取得した場合、valueが更新され、notifyListenersが呼ばれます。

addListenerで状態を監視することで通知が来たときになにかしらの処理を行うことが可能です。

Android用の通知設定androidNotificationChannelTitleandroidNotificationChannelDescriptionを必ず指定してください。androidNotificationChannelIdを合わせることでAndroidでも通知の受け取りが可能になります。

Inheritance
Implemented types

Constructors

PushNotification({PushNotificationMasamuneAdapter? adapter})
Class for handling FirebaseMessaging.

Properties

adapter PushNotificationMasamuneAdapter
TAdapter to be used.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
listening bool
Returns true if notification receipt has been initiated.
no setter
primaryAdapter PushNotificationMasamuneAdapter
Specifies the default TAdapter if adapter is Null.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value PushNotificationValue?
The content of the most recent notice received.
no setteroverride

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
getToken() Future<String?>
Obtain the FCM token for this terminal.
listen() Future<void>
Start receiving notifications.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
send({required String title, required String text, String? channel, DynamicMap? data, required String target}) Future<void>
Start the Functions for sending FCM notifications deployed in FirebaseFunctions.
setValueInternal(PushNotificationValue? value) → void
Set method is used to update the current state.
inherited
subscribe(String topic) Future<void>
Subscribe to a topic named topic.
toString() String
A string representation of this object.
inherited
unsubscribe(String topic) Future<void>
Unsubscribe from a topic name named topic.

Operators

operator ==(Object other) bool
The equality operator.
inherited