android - getExpoPushTokenAsync 在 Android 测试设备上没有响应
问题描述
我知道有一些关于“独立”设备的类似帖子,但这是关于与 Expo XDE 相关的(仍然)测试设备。
简而言之:
我正在尝试使用 getExpoPushTokenAsync 获取推送通知令牌,这对 iphone 非常有效,但不适用于 android 手机
代码: token = await Notifications.getExpoPushTokenAsync(); –> 返回 iphone 的令牌,但在 Android 上没有任何反应(甚至没有任何后续的 console.log)
就在之前: const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS); –> 返回“授予”</p>
我正在使用:“expo”:“^36.0.0”,
// if no existing permission ask user for permission
console.log("status: -" + status + '-');
if (status !== 'granted') {
// Android remote notification permissions are granted during the app
// install, so this will only ask on iOS
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
}
// If no permission, exit ...
if (finalStatus !== 'granted') {
return;
}
// Get the token that uniquely identifies this device
console.log("BEFORE TOKEN....");
let token = await Notifications.getExpoPushTokenAsync();
console.log("TOKEN: " + token);
输出安卓:
status: -granted-
TOKEN BEFORE....
输出 iPhone:
status: -granted-
TOKEN BEFORE....
TOKEN: ExponentPushToken[Xxxxx_Xxxxxxxxxxxxxx]
解决方案
推荐阅读
- php - 从json_encode嵌套数组php中的手镯中删除双引号
- javascript - onSubmitEditing 永远不会触发?
- vb.net - 动态调用不是控件的对象
- java - 如何在 Java 中发现多播地址范围?
- android - 如何在我的 AppbarLayout 之后放置我的 NestedScrollView
- java - 从资产中读取对象
- spring-boot - 如何在 Springboot 应用程序中优雅地停止骆驼上下文
- sql - 我想从单个消息列 sql 查询中提取列
- mongodb - 如何在批量插入中跳过重复文档并忽略具有特定字段 c# 的重复项
- mongodb - Docker 内 mongo 中的 shell 命令无法进行身份验证