【发布时间】:2020-04-28 01:08:15
【问题描述】:
我使用 Expo 推送通知通过推送令牌向 GSM 发送通知。 我的代码是:
registerForPush = async () => {
if (Constants.isDevice) {
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS,
);
let finalStatus = existingStatus;
if (existingStatus !== 'granted') {
const { status } = await Permissions.askAsync(
Permissions.NOTIFICATIONS,
);
finalStatus = status;
}
if (finalStatus !== 'granted') {
alert('Failed to get push token for push notification!');
return;
}
const gsm = await Notifications.getExpoPushTokenAsync();
this._storeData('TOKEN_GSM', gsm);
} else {
alert('Must use physical device for Push Notifications');
}
};
async componentDidMount() {
this.registerForPush();
}
当我使用 Expo 运行应用程序时,我手动授予了获取令牌的权限,但现在我弹出应用程序以使用 Xcode 运行 IOS 项目。 我收到一个错误,我无法获取推送令牌: 推送通知获取推送令牌失败
【问题讨论】:
标签: ios react-native push-notification expo native