【发布时间】:2019-03-15 17:34:28
【问题描述】:
我正在使用 react-native 和 amplify 通过 AWS Pinpoint 向设备发送推送通知。我可以获得设备的生成令牌。但我只需要使用用户 ID 发送推送通知。我尝试更新端点,但它不起作用。谁能建议我处理这个问题的正确方法?
PushNotification.onRegister((token) => {
console.log('in app registration', token);
Analytics.updateEndpoint({
address: token,
channelType: "GCM",
OptOut: 'NONE',
userId: "12345"
}).then(data => {
console.log(data)
}).catch(error => {
console.log(error)
});
});
【问题讨论】:
-
你是如何在 react-native android 中获得设备令牌的?我有这个关于删除设备令牌的问题,请你看看:github.com/aws-amplify/amplify-js/issues/3080
-
@Lucky_girl 你必须在启动 .js (App.js) 文件中添加放大方法。我也遇到了这个问题,我将
onRegister方法移动到启动.js 文件,然后我就能够获得注册的令牌。 -
我已经在componentDidMount()中把它移到了App.js中,但是仍然无法在那里获取token。你使用标准的 react-native 还是 expoKit?
-
我使用的是 react-native init 而不是博览会。你添加了 firebase Api Key 吗?
-
是的!您使用什么版本的 aws-amplify 和 aws pushnotifications?
标签: android amazon-web-services react-native aws-amplify aws-pinpoint