-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for SBM V2 #7
base: main
Are you sure you want to change the base?
Conversation
if (Platform.OS === 'ios') { | ||
PushNotificationIOS.addEventListener('notification', async notification => { | ||
if (isClicked && isSendbirdNotification(data)) { | ||
sb.markPushNotificationAsClicked(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the markPushNotificationAsXXXX
method is called, the SDK needs to send the stored push token to the server.
If the SDK is not logged in, the sdk.initializeCache(userId)
method needs to be called first to properly retrieve the stored push token from the cache. (SDK's login methods (connect, authenticateFeed) include this cache initialization process.)
for example
if (!sb.currentUser) {
const userId = data.sendbird?.recipient?.id ?? loginInformation.userId;
if (userId) await sdk.initializeCache(userId);
}
sb.markPushNotificationAsDelivered(data);
sb.markPushNotificationAsClicked(data);
const data = notification?.getData(); | ||
const isClicked = data?.userInteraction === 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue was discovered while implementing the latest version of Notifee.
On iOS, when a push notification is clicked, the information that the push notification was clicked is communicated through the didReceiveNotificationResponse
delegate in the native layer (AppDelegate.mm).
Previously, it was possible to handle clicks using react-native-push-notification-ios
, but the latest version of Notifee overrides the implementation of didReceiveNotificationResponse
. (invertase/notifee#925)
As a result, the push click event is not passed to the react-native-push-notification-ios
library from didReceiveNotificationResponse
, causing the previous code to not work.
Instead, the click event can be handled through Notifee's foreground event.
Updating sample app to support SBM V2