0

创建应用程序端点时,不接受设备令牌。Exo 像这样返回令牌ExponentPushToken[91hX**********]

在下面的表格中:

最多 400 个字符。仅允许十六进制字符 ara

我将令牌转换为十六进制它仍然不接受设备令牌。

要在博览会中获取设备令牌,我遵循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;
}
4

1 回答 1

0

根据https://docs.aws.amazon.com/sns/latest/dg/sns-mobile-application-as-subscriber.html#sns-how-user-notifications-work,SNS 未将 Expo 列为受支持平台。

虽然 Expo 支持 iOS 和 FCM,SNS 也支持,但 SNS 不支持 Expo 在这些平台之上添加的附加层。

于 2022-02-23T23:34:55.937 回答