countly-sdk-react-native
countly-sdk-react-native copied to clipboard
SDK should allow the client to determine logic for Data only messages - current assumption on all data only messages is they are to be displayed.
Description:
The countly react-native-sdk makes an assumption that all data only messages via the OnMessage() handler should be displayed, and that they came from countly.
To be on par with the native SDK, see, for example, how the Android SDK handles OnMessage.
OnMessage is handled in the client, and uses a display helper in the Countly SDK.
The Android native Countly SDK looks for a title and message in the data payload, if they don't exist, the display helper returns null.
see:
https://github.com/Countly/countly-sdk-android/blob/5e89ee1b1cfd60381bb4cadd734ee6c86780f87c/sdk-messaging-fcm/src/main/java/ly/count/android/sdk/messaging/CountlyPush.java#L359
https://github.com/Countly/countly-sdk-android/blob/5e89ee1b1cfd60381bb4cadd734ee6c86780f87c/sdk-messaging-fcm/src/main/java/ly/count/android/sdk/messaging/CountlyPush.java#L327
and https://github.com/Countly/countly-sdk-android/blob/1b7d6b964908908dfa41e44248b799a33264670b/app-messaging-fcm/src/main/java/ly/count/android/demo/messaging_fcm/DemoFirebaseMessagingService.java#L32
https://github.com/Countly/countly-sdk-android/blob/1b7d6b964908908dfa41e44248b799a33264670b/app-messaging-fcm/src/main/java/ly/count/android/demo/messaging_fcm/DemoFirebaseMessagingService.java#L90
It looks like the OnMessage handler is in the client app (not the SDK), and there is a CountlyPush.displayMessage helper in the SDK to display the notification.
If it is not a notification from the countly “Message” ui, it falls back to returning null, which means the client application should handle the silent push data.
Or, the data message came from another push service and should be handled and displayed gracefully by the client app, not the Countly SDK.