Closed haohaowasky closed 3 years ago
Hi @haohaowasky that guide is related to android and not flutter
we're writing a detailed guide on how to set up notifications using flutter, but it's not hard
what package are you using for notifications on flutter?
So I'm using stream_chat_flutter.dart
And I see only one method here related to notification which is addDevice. And I have added to that in my code, however, as I said before it seems like some registration issue happening from firebase.
I suggest you take a look at this package to configure notifications https://pub.dev/packages/flutter_apns Our package doesn't handle notifications as it's an external service in a flutter app
So in our end, our requirement is user getting a notification when there is a message received. Pretty much the same feature you guys mentioned at https://getstream.io/chat/docs/flutter-dart/push_introduction/?language=dart&q=mention
The problem is I haven't seen the methods in Flutter SDK
@haohaowasky the only method we provide is addDevice
that you should call once the token of the push notification service is available
To set up notifications you should use a package like flutter_apns (https://pub.dev/packages/flutter_apns) as you would do for any other app
The difference is that you would also use addDevice
to send us the notification token so that we can send you notifications
@haohaowasky you can also configure a webhook endpoint on GetStream portal and deal with the notifications youself. I did this way because flutter_apns is incompatible with other firebase libraries that I was already using
I can confirm firebase_messaging is enough to set up push notifications just have to keep in mind that you have to configure only android in Stream dashboard and always use PushProvider.firebase in the client.addDevice call
it's kind of a workaround, but it works well
I'll close this in favor of #195 to keep track of push notifications I'll update that issue once I finish writing docs
@imtoori I have configured push notification successfully on a flutter app. When I use the CLI test it works and I receive the notification normally. But, when I send a message from the emulator to my device I don't receive the notification nor on the notification logs.
@Aimen-Zelaci can you check that you're respecting the logic you can read here? https://getstream.io/chat/docs/flutter-dart/push_introduction/?language=dart
@imtoori Thank you very much for your quick response. Yes, I am quite sure.
stream chat:push:test --user_id 'user_123'
this works and sends the notification to my device and I also receive it using:
FirebaseMessaging().configure()
.
But not when I send a message.
are you sure the client is not connected? you should put the app in background and wait for the client to disconnect if the user is connected (even on other devices) the notification won't be sent
Hello 👋 Stephen here from the Stream Customer Success department. There could be a few things going wrong here, and in order to properly debug with you, we'd like to know a few things about your app and users. Could you please email support@getstream.io with your app_id, channel_id, and user_id's who are affected. From there, we can make a few checks. Thank you 🙏
@imtoori Yes, I am. I have tried both:
client.connectUser
client.connectUser
and put the app in the background.@imtoori @shodgetts My users were not being added as members, as I thought they were. I'd changed from a 'Messaging' channel to a 'Livestream channel and I believed that members are added as soon as I call channel.watch(), just because users were able to send messages, even without being added as members. After updating channel members, I was finally able to receive FCM notifications. Thank you very much for this quick and interactive response.
I was following with https://getstream.io/chat/docs/flutter-dart/push_android/?language=dart&q=mention
to set up chat notification given we already have the chatting feature setup.
Issues are:
However, when I tried
stream chat:push:test
it gives me error with message:publishing the message failed. code = "200"; error = "InvalidRegistration"
Any idea on what's missing? I'm only testing on Android for now.
gz#10133