我无法获得推送通知的令牌,并且权限不起作用:
未处理的承诺拒绝:TypeError:未定义不是对象(正在评估'_expoPermissions.Permissions.getAsync')
这是代码:
registerForPushNotificationsAsync = async ()=> {
const { status } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
let finalStatus = status;
if (status !== 'granted') {
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
}
if (finalStatus !== 'granted') {
return;
}
let token = await Notifications.getExpoPushTokenAsync();
console.log(token);
}
答案 0 :(得分:0)
权限从“ expo”程序包移至“ expo-permissions”
您必须先安装expo-permissions软件包,然后使用以下语法将其导入
import * as Permissions from 'expo-permissions';