通过AWS Pinpoint将推送通知发送给指定的用户

问题描述 投票:2回答:2

我正在使用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)
  });
});
android amazon-web-services react-native aws-amplify aws-pinpoint
2个回答
0
投票

使用Amazon Pinpoint,您无法将交易消息作为推送通知发送。这意味着,您无法向特定收件人发送直接推送通知。

Amazon Pinpoint - 推送通知支持通过创建广告系列和细分来向目标受众发送通知。

如果仅用于测试,则可以从Pinpoint仪表板中使用用户ID或使用设备令牌将测试消息发送给特定用户。

在这里阅读更多内容=> Sending Transactional Messages from Your Apps - Amazon Pinpoint


0
投票

我能够使用@aws-amplify/analytics库来做到这一点。以下是我使用的方法。

Analytics.configure(aws_exports);

PushNotification.onRegister((token) => {
        //alert(token) 
        console.log('in app registration', token);
        Analytics.updateEndpoint({
            address: token, // The unique identifier for the recipient. For example, an address could be a device token, email address, or mobile phone number.
            attributes: {
              // Custom attributes that your app reports to Amazon Pinpoint. You can use these attributes as selection criteria when you create a segment.
              hobbies: ['piano', 'hiking'],
              interests: ['basketball']
            },
            channelType: 'GCM', // The channel type. Valid values: APNS, GCM
            userId: '221XWsdfER234',
            // User attributes
            optOut: 'ALL',
            userAttributes: {
                interests: ['football', 'basketball', 'AWS']
                // ...
            }
        }).then((data) => {
            console.log(data)
        }).catch(error => {
            console.log(error)
        })

    });
© www.soinside.com 2019 - 2024. All rights reserved.