Skip to content
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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Update for SBM V2 #7

wants to merge 24 commits into from

Conversation

tylerhammer
Copy link
Collaborator

Updating sample app to support SBM V2

@tylerhammer tylerhammer requested a review from bang9 April 25, 2024 03:10
@tylerhammer tylerhammer self-assigned this Apr 25, 2024
ios/sbm/AppDelegate.mm Outdated Show resolved Hide resolved
src/utils/push.js Outdated Show resolved Hide resolved
if (Platform.OS === 'ios') {
PushNotificationIOS.addEventListener('notification', async notification => {
if (isClicked && isSendbirdNotification(data)) {
sb.markPushNotificationAsClicked(data);
Copy link
Collaborator

@bang9 bang9 May 21, 2024

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);

Comment on lines +105 to +106
const data = notification?.getData();
const isClicked = data?.userInteraction === 1;
Copy link
Collaborator

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.

Example: https://github.com/sendbird/react-native-sample-notifications-war-room/pull/1/files#diff-16197fad13a80965a19877fb31010a9a4a011f3b406de9e9ed7f1e05e7bd9528R68-R77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants