Retrieving Native Device Tokens on Android


#1

Hi all!

I’m trying to retrieve native device tokens/registration IDs in our standalone app, using the following code:

const { status: existingStatus } = await Permissions.getAsync(
  Permissions.NOTIFICATIONS,
);

let finalStatus = existingStatus;

// only ask if permissions have not already been determined, because
// iOS won't necessarily prompt the user a second time.
if (existingStatus !== "granted") {
  // Android remote notification permissions are granted during the app
  // install, so this will only ask on iOS
  const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
  finalStatus = status;
}

// Stop here if the user did not grant permissions
if (finalStatus !== "granted") {
  return;
}

// Get the token that uniquely identifies this device
const { data: token, type: platform } = await Notifications.getDevicePushTokenAsync();

This all seems to be working fine on iOS, however on Android, I get this error thrown:

Cannot convert argument of type class com.facebook.react.bridge.WritableNativeMap

Any ideas on what I’m doing wrong here? Could there be any configuration issues with FCM or otherwise that could be causing this?

Many thanks!