Potential error with sending notifications
Hi there, great package, it's proving very useful so far. I'm having issues trying to send a notification without error and have tried most of the API surface. I could do with understanding whether this is a bug in the implementation or if I'm doing something wrong.
Approach 1:
var messaging = initializeApp().messaging();
var result = await messaging
.send(TokenMessage(
token: token,
android: AndroidConfig(
notification: AndroidNotification(title: "title", body: "body"),
),
))
.catchError((e) => Exception(e));
This returns the error: NoSuchMethodError: method not found: 'toString' on null. I know the app and token are non-null and that this is the point of error.
Here I'm using the AndroidConfig as a potential workaround to using notification: NotificationPayload as I was having to extend NotificationPayload for my code to be valid and was trying to rule everything out.
Approach 2 (based on NodeJS documentation):
var message = {
'Message': {
'token': token,
'notification': {'title': 'title', 'body': 'body'}
}
};
var method1 = await messaging.send(message).catchError((e) => print(e));
This returns the error: Error: Exactly one of topic, token or condition is required which I assume is from Firebase itself.
I have also tried permutations with .sendToDevice(), .sendToDeviceGroup() and others without luck, normally receiving the NoSuchMethodError: method not found: 'toString' on null error.
Is there a working example I could test?