代码之家  ›  专栏  ›  技术社区  ›  Pedro Martins de Souza Regeesh Chandran

AWS Pinpoint/Ionic尝试通过CLI发送推送时出现“未找到资源”错误

  •  0
  • Pedro Martins de Souza Regeesh Chandran  · 技术社区  · 8 年前

    我对使用AWS服务编程很陌生,所以一些基本的东西对我来说很难。最近,我被要求开发一个使用amazonpoint发送推送通知的应用程序,作为考虑未来实现的测试。

    你可以在我贴在这里的另一个问题中看到( Amazon Pinpoint and Ionic - Push notifications not working when app is in background these steps .

    当我几乎要放弃的时候,我决定试着直接发送推送 火基 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": ""
                }
            }
        }
    }
    

    但当我在命令行中用 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文件,因为这是我第一次这样做。所以,如果你们知道我做错了什么,不管我误解了哪一步,我都会感激你们的帮助!

    1 回复  |  直到 8 年前
        1
  •  1
  •   Balaji Sankar    8 年前

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

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

    下面是一个使用AmazonPinpoint发送直接消息的示例注意:这个示例处理发送SMS消息。您应该先注册一个SMS通道,然后创建一个端点id为“test-endpoint1”的端点。否则,可以使用“Addresses”字段而不是“Endpoints”字段。

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

    另请注意

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

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