react-native - 我在 react native (android) 项目中没有收到来自 AWS Pinpoint 的推送通知
问题描述
我已遵循官方AWS Pinpoint 指南,但我无法在我的设备上接收推送通知。
我的步骤:
我的 Firebase 项目配置正确,我能够从 Firebase 控制台接收推送通知
我在 AWS Pinpoint 控制台中启用了推送通知,并在那里添加了 API 密钥和发件人 ID
我在项目中做了这些命令:
npm install @aws-amplify/pushnotification --save
react-native link @aws-amplify/pushnotification
- 在 App.js 中添加了分析和推送通知的配置
Amplify.configure({
Auth: {
region: 'xxx',
userPoolId: 'xxx',
userPoolWebClientId: 'xxx',
mandatorySignIn: true
},
API: {
endpoints: [{
name: "xxx",
endpoint: "xxxx",
custom_header: async () => ({ Authorization: await getAuthorizationToken() })
}]
},
Analytics: {
disabled: false,
AWSPinpoint: {
appId: 'xxxxxx',
region: 'xxxx',
}
}
});
PushNotification.configure({
appId: 'xxxx',
region: 'xxxx',
});
App.js
在方法中的 componentDidMount 中添加onRegister
:
componentDidMount(){
PushNotification.onRegister((token) => {
console.log('in app registration', token);
});
}
- 登录后添加此
updateEndpoint
方法:
Analytics.updateEndpoint({
address: 'xxxx',
channelType: 'GCM',
userId: '1',
})
- 我试图在
AWS Pinpoint
控制台中创建测试活动,但控制台没有看到任何设备,也没有向手机发送任何内容。
我错过了什么?如何让它发挥作用?
解决方案
推荐阅读
- javascript - 为什么这个事件总是触发?
- android - 使用任何一个
与 Firestore - amazon-s3 - 使用带有签名 Cookie 的 AWS Cloudfront 的 CORS 问题。AllowedOrigin 未设置为标头中传递的内容
- azure-devops - Azure DevOps REST 代理请求缺少最后一个已完成的属性
- java - 骆驼onException后的多个处理程序
- apache-kafka - 当并发级别小于分区号时,Spring Kafka SeekToCurrentErrorHandler maxFailures 不起作用
- php - 类定义被调用两次?无法为 symfony3.4 声明类错误
- ios - 径向 CAGradientLayer 在运行时无法正确渲染
- python - 无法为 git-bash 配置 python 和 anaconda:
- stream - flink如何处理两个流通过键连接,但没有匹配的键