简体   繁体   English

到GCM的AWS SNS通知不起作用

[英]AWS SNS notifications to GCM not working

I am trying to send SNS notification to my app using a GCM endpoint. 我正在尝试使用GCM端点向我的应用发送SNS通知。

The message is as follows 消息如下

{"default":"notification 7","GCM":"{ \"data\": { \"message\": \"notification 7\" } }"}

It is showing success on the cloudwatch log. 它在cloudwatch日志中显示成功。 But message does not reach the device. 但是消息无法到达设备。 Any setting that i am forgetting? 我忘记了任何设置吗?

This is the snippet of my code 这是我的代码的片段

    static {
    try {
        ClasspathPropertiesFileCredentialsProvider credentialsProvider =  new ClasspathPropertiesFileCredentialsProvider(Constants.APPPROPERTIESFILE);
            snsClient =  (AmazonSNSClientBuilder.standard().withRegion(Regions.US_WEST_2).withCredentials(new AWSStaticCredentialsProvider(credentialsProvider.getCredentials()))).build();
    }
    catch (Exception e) {
        logger.info("Some exception " + e);
    }
    }

    PublishResult snsres = snsClient.publish(publishRequest);

I get a message id and success as returned value. 我得到消息ID和成功作为返回值。

Thank you for your time. 感谢您的时间。 The json format was wrong. json格式错误。 The data property has a string value rather than a json. data属性具有字符串值而不是json。 Hence I did a jsonobj.toString() and the notifications worked. 因此,我做了一个jsonobj.toString(),通知工作了。 Not only that, I can now add any custom property value I need to. 不仅如此,我现在可以添加所需的任何自定义属性值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM