首页 > 解决方案 > 我在 react native (android) 项目中没有收到来自 AWS Pinpoint 的推送通知

问题描述

我已遵循官方AWS Pinpoint 指南,但我无法在我的设备上接收推送通知。

我的步骤:

  1. 我的 Firebase 项目配置正确,我能够从 Firebase 控制台接收推送通知

  2. 我在 AWS Pinpoint 控制台中启用了推送通知,并在那里添加了 API 密钥和发件人 ID

  3. 我在项目中做了这些命令:

npm install @aws-amplify/pushnotification --save
react-native link @aws-amplify/pushnotification

  1. 在 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',
}); 
  1. App.js在方法中的 componentDidMount 中添加onRegister
componentDidMount(){
  PushNotification.onRegister((token) => {
    console.log('in app registration', token);
  });
}
  1. 登录后添加此updateEndpoint方法:
Analytics.updateEndpoint({
  address: 'xxxx',
  channelType: 'GCM',
  userId: '1',
}) 
  1. 我试图在AWS Pinpoint控制台中创建测试活动,但控制台没有看到任何设备,也没有向手机发送任何内容。

我错过了什么?如何让它发挥作用?

标签: react-nativereact-native-androidaws-amplifyaws-pinpoint

解决方案


推荐阅读