ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
124 stars 111 forks source link

Chat Notification not showing when app is in foreground #201

Closed mikeangelsilva closed 3 years ago

mikeangelsilva commented 3 years ago

I do only recieve notification when the app is in background/kill. But when the app is in foreground, notification wont show.

Do i need to pass something on the payload, or is there any configuration on that?

Thank you.

DaveLomber commented 3 years ago

For when the app is foreground, the recommended way is NOT to rely on push notifications. Instead - use regular chat connection for it and display local notifications when receive chat message

mikeangelsilva commented 3 years ago

@DaveLomber hi,do you have idea on how to pass payload using local notification ?

https://github.com/react-native-push-notification-ios/push-notification-ios i used react-native-push-notification-ios

PushNotificationIOS.addNotificationRequest(request);

i tried it, but i cant get the dialog data when i passed it.

thank you :)

DaveLomber commented 3 years ago

@mikeangelsilva use this API

https://github.com/react-native-push-notification-ios/push-notification-ios#schedulelocalnotification

stevenblake-banntech commented 3 years ago

So my solution so far:

These two in isolation work fine. The problem is that when I receive a remote push notification I receive it then open the app, and then a local notification is fired from the onMessageListener.

As we cannot display remote notifications in the foreground, can anyone recommend a solution?

DaveLomber commented 3 years ago

@stevenblake-banntech you mean you have 2 notifications displayed instead of one?

aravi365 commented 3 years ago

So my solution so far:

  • onMessageListener will display a local notification when a message is received
  • subscribe to remote push notifications which works when a message is received and app is closed or in the background.

These two in isolation work fine. The problem is that when I receive a remote push notification I receive it then open the app, and then a local notification is fired from the onMessageListener.

As we cannot display remote notifications in the foreground, can anyone recommend a solution?

i know its out of topic, but it would be great if you can help me in how to add onMessage listener in a function component. @stevenblake-banntech @DaveLomber