【发布时间】:2019-03-25 07:37:31
【问题描述】:
我正在为我的应用程序使用 expo 通知,它在 ios 上运行良好,但在 android 上不起作用。我进行通知的方式是通过以下代码获取密钥
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS
);
let finalStatus = existingStatus;
// only ask if permissions have not already been determined, because
// iOS won't necessarily prompt the user a second time.
if (existingStatus !== '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;
}
// Stop here if the user did not grant permissions
if (finalStatus !== 'granted') {
return;
}
// Get the token that uniquely identifies this device
let token = await Notifications.getExpoPushTokenAsync();
alert(token)
然后将令牌保存在服务器中并发送如下通知:
发帖方式 https://exp.host/--/api/v2/push/send
{
"to": "ExponentPushToken[HOKJqEF5FdGLRO7s-Kg4Ns]",
"title":"Test",
"body": "Test"
}
我是否必须使用 firebase FCM 才能使其在 Android 中运行?
【问题讨论】:
标签: android notifications expo