当我尝试获取用户的expo推送令牌时,出现[TypeError:undefined不是对象(正在评估_PushTokenManager.default.getDevicePushTokenAsync”)错误。而且我还在Android设备上运行该应用。谁能帮我解决这个问题?
import * as Notifications from "expo-notifications";
import * as Permissions from "expo-permissions";
const AppNavigator = () => {
useEffect(() => {
registerForPushNotifications();
}, []);
const registerForPushNotifications = async () => {
const permission = await Permissions.askAsync(Permissions.NOTIFICATIONS);
if (!permission.granted) {
return;
}
const token = await Notifications.getExpoPushTokenAsync();
expoPushTokensApi.register(token); // sending the token to the server
console.log(token);
};
return {}
}