So i am trying to register a push notification for sendbird in my react native chat app but couldn't make it , can someone please give me hint or a tutorial so i can flw or someone can connect with me

So i am trying to register a push notification for sendbird in my react native chat app but couldn’t make it , can someone please give me hint or a tutorial so i can flw or someone can connect with me

Hello @Vidhi_Tomar, Welcome to Sendbird Community!

Could you let me know whether you are using the Sendbird Chat SDK or the UIKit with your React Native Chat application?

hwy thanks for connecting , i am using react native ui kit

Thanks for sharing.

You can find detailed instructions for setting up Push notifications in React Native UIKit here - Authentication | UIKit React Native SDK | Sendbird Docs

Please let us know if you have any questions or run into any issues.

i already did this i m asking for register push token for sendbird server step

const getTokenForSendbird = async () => {
if (Platform.OS === ‘ios’) {
const token = await messaging().getAPNSToken();
try {
const response = await sb.registerAPNSPushTokenForCurrentUser(token);
// Do something in response to a successful registration.
} catch (error) {
// Handle error.
}
} else {
const token = await messaging().getToken();
try {
const response = await sb.registerGCMPushTokenForCurrentUser(token);
console.log(response, ‘sendbird token’);
// Do something in response to a successful registration.
} catch (error) {
// Handle error.
}
}
}

By default push token registration is enabled for each user after you set ‘NotificationServiceInterface’ in ‘SendbirdUIKitContainer’ as a platform service as shown in below code.

import RNFBMessaging from '@react-native-firebase/messaging';
import * as Permissions from 'react-native-permissions';
import { SendbirdUIKitContainer, createNativeNotificationService } from '@sendbird/uikit-react-native';

const NotificationService = createNativeNotificationService({
    messagingModule: RNFBMessaging,
    permissionModule: Permissions,
});

const App = () => {
    return (
        <SendbirdUIKitContainer
            appId={'APP_ID'}
            platformServices={{ notification: NotificationService }}
        />
    );
};

for refrence i am following this blog
https://sendbird.com/developer/tutorials/implement-react-native-app-push-notifications
i am asking for how to genrate sendbird push token for serndbord server see here is my that ran it in useeffect

const getTokenForSendbird = async () => {

  const token = await messaging().getToken();
  try {
    const response = await sb.registerGCMPushTokenForCurrentUser(token);
    console.log(response, 'sendbird token');
    // Do something in response to a successful registration.
  } catch (error) {
    console.log(error , 'sb errorv')
    // Handle error.
  }

}

useEffect(() => {

//fcm token is device token genrated by firebase
getTokenForSendbird(fcmToken)
}, );

Thanks for sharing the code.

I see that you are using Sendbird Javascript Chat SDK in your React Native application the code you have shared looks fine so to register the device token in the sendbird server you should also “Allow notifications” in your device when the permission is prompted.

If you are still facing any issues, you can also refer to our sample application.

**[quote=“uday.bhaskar, post:9, topic:7496, full:true”]
Thanks for sharing the code.

I see that you are using Sendbird Javascript Chat SDK in your React Native application the code you have shared looks fine so to register the device token in the sendbird server you should also “Allow notifications” in your device when the permission is prompted.

If you are still facing any issues, you can also refer to our sample application.
[/quote]

**
hi uday! i just tried and still facing same problem see
i ran the code for Register a push token to the Sendbird server
here is my code


const getTokenForSendbird = async () => {
   
      const token = await messaging().getToken();
      console.log(token , '>>>>>>>>>>>>')
      try {
        const response = sb.registerGCMPushTokenForCurrentUser(token);
        console.log(response, 'sendbird token ^^^^^');
        // Do something in response to a successful registration.
      } catch (error) {
        console.log(error , 'sb errorv')
        // Handle error.
      }
    
  }

and i consle the toke before calling the sb.registerGCMPushTokenForCurrentUser(token)
it consoled the right fcm token now come to response it is consoling


 LOG  {"_h": 0, "_i": 1, "_j": "pending", "_k": null} sendbird token ^^^^^