ConnectyCube / connectycube-flutter-samples

Code samples for Flutter, based on ConnectyCube platform
https://developers.connectycube.com/flutter/
Apache License 2.0
85 stars 90 forks source link

I want to use Firebase FCM instead of APNS, #262

Closed Badar25 closed 1 year ago

Badar25 commented 1 year ago

I want to use Firebase FCM instead of APNS, but in console i dont have any option to see or customize the FCM payload such. as adding new key params. Im not talking about data notification

Badar25 commented 1 year ago

Provide us customization to FCM payload so we can configure the field ourself. Rightnow, in my app, I can get all notification (not from your SDK), except notification generating from your sdk.

Acutally FIrebase onMessageListen its not catching it, not even in terminated state. Its just catching when app is open but in background thats it.

Do you guys have any idea? Im using FCM (gcm) channel for iOS

TatankaConCube commented 1 year ago

could you please specify what data you required in the FCM push notification for iOS?

TatankaConCube commented 1 year ago

have you tried to enable the "Notifications" push type for FCM in the Connectycube admin panel?

Screenshot 2023-06-05 at 11 08 32
Badar25 commented 1 year ago

Im actually not getting fcm msgs from onListen method in flutter On Mon, Jun 5, 2023 at 1:10 PM TatankaConCube @.***> wrote:

have you tried to enable the "Notifications" push type for FCM in the Connectycube admin panel? [image: Screenshot 2023-06-05 at 11 08 32] https://user-images.githubusercontent.com/48598737/243291667-e58c87a6-fb07-4f23-9203-f7e84082647d.png

— Reply to this email directly, view it on GitHub https://github.com/ConnectyCube/connectycube-flutter-samples/issues/262#issuecomment-1576304996, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5C5RMIBC5T54JQ6QSML35LXJWH7HANCNFSM6AAAAAAYZJ5B34 . You are receiving this because you authored the thread.Message ID: @.*** com>

TatankaConCube commented 1 year ago

I modified our Chat sample a little bit. And it can receive FCM push notifications in the same way as Android. The callbacks onMessageOpenedApp and onBackgroundMessage work well on the iOS side. I suppose other callbacks should work on iOS in the same way as Android.

A few notes:

Badar25 commented 1 year ago

Youre right, im using fcm in ios (gcm) that means not depending upon on apns.

Im generating notifications from postman, im able to receive but not getting from cc server (just onMessage.listen) rest of listeners are working fin.

On Mon, Jun 5, 2023 at 8:00 PM TatankaConCube @.***> wrote:

I modified our Chat sample a little bit. And it can receive FCM push notifications in the same way as Android. The callbacks onMessageOpenedApp and onBackgroundMessage work well on the iOS side. I suppose other callbacks should work on iOS in the same way as Android.

A few notes:

  • you should create the subscription on iOS in the same way as Android;
  • the iOS system returns the dev token even if you build a release build, except if you build an archive to TestFlight, in this case, the system returns the production token, which means you should add both *.p12 certificates to the firebase developer console;

— Reply to this email directly, view it on GitHub https://github.com/ConnectyCube/connectycube-flutter-samples/issues/262#issuecomment-1576965464, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5C5RMKGJSVHH3MHB7JHS6LXJXYAZANCNFSM6AAAAAAYZJ5B34 . You are receiving this because you authored the thread.Message ID: @.*** com>

TatankaConCube commented 1 year ago

on my side, the callback onMessage triggers too. are you sure that you have marked the chat connection inactive for receiving Chat push notifications? could you please add some details on how you check FCM from Connectycube?

Badar25 commented 1 year ago

what does that mean? "marked the chat connection inactive for receiving Chat push notification"

Badar25 commented 1 year ago

Not even this below code is printing, but when I send a notification from postman, its getting called but not from ConnectyCube server FCM.

If app is in background, terminated state, i am able to catch it, but when app is open I am not able able to recieve notification which should be listen by below code.

FirebaseMessaging.onMessage.listen((message) async {
        debugPrint('onMessage: $message');  
});
TatankaConCube commented 1 year ago

you will receive push notifications about the chat messages only in case when you are don't connected to the chat. for it you can logout from chat using CubeChatConnection.instance.logout() or you can mark the chat connection inactive using CubeChatConnection.instance.markInactive()

TatankaConCube commented 1 year ago

If app is in background, terminated state, i am able to catch it, but when app is open I am not able able to recieve notification which should be listen by below code.

it is expected behavior because in our sample we mark the chat connection as inactive when moving to the background, the callback onMessage works in case when the app is in foreground state

Badar25 commented 1 year ago

Sorry, its not working :(

TatankaConCube commented 1 year ago

What exactly doesn't work?

Badar25 commented 1 year ago

Not getting the notification even tho I marked '''CubeChatConnection.instance.markInactive()'''

Badar25 commented 1 year ago

Is there any way i can disable this behaviour at all? '''CubeChatConnection.instance.markInactive()'''

TatankaConCube commented 1 year ago

It doesn't make sense. When you have an active chat connection you will receive messages through it. When you are disconnected you will receive the push notification.

Badar25 commented 1 year ago

It doesn't make sense. When you have an active chat connection you will receive messages through it. When you are disconnected you will receive the push notification.

In my scenario I had to, Anyhow marking as closed as I have completely disabled this markInactive/active from main.dart and it got working 😄.