【问题标题】:AWS Pinpoint/Ionic - "Resource not found" error when trying to send push through CLIAWS Pinpoint/Ionic - 尝试通过 CLI 发送推送时出现“找不到资源”错误
【发布时间】:2018-12-14 10:06:51
【问题描述】:

我是使用 AWS 服务编程的新手,所以一些基本的东西对我来说相当困难。最近,我被要求开发一个使用 Amazon Pinpoint 发送推送通知的应用程序,作为考虑未来实施的测试。

正如您在我在这里发布的另一个问题 (Amazon Pinpoint and Ionic - Push notifications not working when app is in background) 中看到的,当我的应用在后台运行时,我在尝试向用户发送推送通知时遇到了麻烦。该应用是使用 Ionic 开发的,关注 these steps

当我快要放弃的时候,我决定尝试直接通过 Firebase 发送推送,终于成功了。一些研究将我带到this question,其中另一位用户将问题描述为仅发生在 AWS 控制台中,因此解决方案是使用 CLI。经过一番搜索,我找到了this tutorial about how to sending pinpoint messages to users using CLI,这似乎就是我想要的。将它与this documentation about phonegap plugin 结合,我能够生成一个我认为可能是解决方案的 JSON:

{
    "ApplicationId":"io.ionic.starter",
    "MessageRequest":{
        "Addresses": {
            "": {
                "BodyOverride": "",
                "ChannelType": "GCM",
                "Context": {
                    "": ""
                },
                "RawContent": "",
                "Substitutions": {},
                "TitleOverride": ""
            }
        },
        "Context": {
            "": ""
        },
        "Endpoints": {"us-east-1": {
            "BodyOverride": "",
            "Context": {},
            "RawContent": "",
            "Substitutions": {},
            "TitleOverride": ""
          }
        },
        "MessageConfiguration": {

            "GCMMessage": {
                "Action": "OPEN_APP",
                "Body": "string",
                "CollapseKey": "",
                "Data": {
                    "": ""
                },
                "IconReference": "",
                "ImageIconUrl": "",
                "ImageUrl": "",
                "Priority": "High",
                "RawContent": "{\"data\":{\"title\":\"sometitle\",\"body\":\"somebody\",\"url\":\"insertyourlinkhere.com\"}}",
                "RestrictedPackageName": "",
                "SilentPush": false,
                "SmallImageIconUrl": "",
                "Sound": "string",
                "Substitutions": {},
                "TimeToLive": 123,
                "Title": "",
                "Url": ""
            }
        }
    }
}

但是当我在 cmd 中使用 aws pinpoint send-messages --color on --region us-east-1 --cli-input-json file://test.json 执行它时,我得到了响应 An error occurred (NotFoundException) when calling the SendMessages operation: Resource not found

我认为我没有正确编写 JSON 文件,因为这是我第一次这样做。所以,如果你们中的任何人知道我做错了什么,无论我误解了哪一步,我都将不胜感激!

【问题讨论】:

    标签: amazon-web-services cordova ionic-framework push-notification


    【解决方案1】:

    消息请求中的“Endpoints”字段处理端点 id(与最终用户设备关联的标识符,同时注册到 pinpoint 而不是区域。)

    如果您尚未向 Pinpoint 注册任何端点,您可以使用“地址”字段。在 Amazon Pinpoint 中注册 GCM 通道后,您可以从您的设备获取 GCM 设备令牌并在此处指定。

    这是使用 Amazon Pinpoint 发送直接消息的示例 注意:该示例处理发送 SMS 消息。您应该首先注册一个 SMS 通道并创建一个端点 ID 为“test-endpoint1”的端点。否则,您可以使用“地址”字段而不是“端点”字段。

     aws pinpoint send-messages --application-id $APP_ID --message-request '{"MessageConfiguration": {"SMSMessage":{"Body":"hi hello"}},"Endpoints": {"test-endpoint1": {}}}
    

    另请注意:ApplicationId 由 Pinpoint 生成。当您访问 Pinpoint 控制台并选择您的应用程序时,URL 将采用以下格式

    https://console.aws.amazon.com/pinpoint/home/?region=us-east-1#/apps/someverybigstringhere/
    

    这里的“someverybigstringhere”是 ApplicationId,而不是您为项目指定的名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-23
      • 2017-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-18
      相关资源
      最近更新 更多