0

While creating application endpoint, device token is not accepted. Exo returns token like that ExponentPushToken[91hX**********]

in the below the form it is written :

Maximum 400 characters. Only hexadecimal characters ara allowed

I convert to token to hexadecimal it still not accept device token.

to get device token in expo I follow expo-notification guide.

async function registerForPushNotificationsAsync() {
  let token;
  if (Device.isDevice) {
    const { status: existingStatus } = await Notifications.getPermissionsAsync();
    let finalStatus = existingStatus;
    if (existingStatus !== 'granted') {
      const { status } = await Notifications.requestPermissionsAsync();
      finalStatus = status;
    }
    if (finalStatus !== 'granted') {
      alert('Failed to get push token for push notification!');
      return;
    }
    token = (await Notifications.getExpoPushTokenAsync()).data;
    console.log(token);
  } else {
    alert('Must use physical device for Push Notifications');
  }

  if (Platform.OS === 'android') {
    Notifications.setNotificationChannelAsync('default', {
      name: 'default',
      importance: Notifications.AndroidImportance.MAX,
      vibrationPattern: [0, 250, 250, 250],
      lightColor: '#FF231F7C',
    });
  }

  return token;
}

2 Answers2

0

As per https://docs.aws.amazon.com/sns/latest/dg/sns-mobile-application-as-subscriber.html#sns-how-user-notifications-work, SNS does not list Expo as a supported platform.

While Expo supports iOS and FCM, which are also supported by SNS, SNS does not support the additional layer Expo adds on top of these platforms.

bjrnt
  • 2,552
  • 3
  • 27
  • 38
0

You need to use getDevicePushTokenAsync() instead of getExpoPushTokenAsync() If you aren't using the Expo notification service directly.

cr0ybot
  • 3,960
  • 2
  • 20
  • 22