使用Spring Cloud Aws消息发送推送通知的问题

时间:2018-09-28 20:33:41

标签: spring-cloud amazon-sns spring-cloud-aws

当我通过aws控制台发送一条消息,调试我的android应用程序时,我得到了android.os.Bundle类的实例,该实例包含一些键值,其中包含一个名为“ message”的键,其值为我的有效负载,当我从Spring应用程序发送相同的消息时,android的Bundle类获得相同的地图,但是键的值名为“ default”而没有“ message”,我一直在阅读这种行为,我已经确定默认情况下,当服务无法读取“ GCM”属性的内容时,它将发送“默认”属性的内容。有人帮助我为什么在我的Spring项目中使用这种行为不同的控制台吗?

我的Spring应用程序:

@Component
public class AmazonSnsAdapter implements PushSender {

    private static Logger LOG = LoggerFactory.getLogger(AmazonSnsAdapter.class);

    @Autowired
    NotificationMessagingTemplate notificationMessagingTemplate;

    @Override
    public void send(Push push) {

        String payload = "{\"default\":\"show this atributte when have a problem\",\"GCM\":\"{\"data\":{\"message\":\"dont show this\"}}\"}";

        notificationMessagingTemplate.sendNotification("push-notification", payload, "test");

    }

}

通过aws控制台收到推送时调试android:

I/System.out: google.delivered_priority :Valor normal
I/System.out: google.sent_time :Valor 1538166353259
              google.ttl :Valor 2419200
I/System.out: google.original_priority :Valor normal
I/System.out: google.message_id :Valor 0:1538166353270393%9aea4af7f9fd7ecd
I/System.out: message :dont show this

当我的Spring应用程序收到推送时。

I/System.out: google.delivered_priority :Valor normal
I/System.out: google.sent_time :Valor 1538166580450
              google.ttl :Valor 2419200
I/System.out: google.original_priority :Valor normal
              google.message_id :Valor 0:1538166580460225%9aea4af7f9fd7ecd
I/System.out: default :show this atributte when have a problem

我正在使用:

springBootVersion = '2.0.1.BUILD-SNAPSHOT'
springCloudVersion = 'Greenwich.BUILD-SNAPSHOT'
compile('org.springframework.cloud:spring-cloud-starter-aws-messaging')

0 个答案:

没有答案