AWS SNS not showing push notifications in the notification center anymore

Viewed 78

I had working code with the Java-SNS-SDK. The short version of it is:

sendMessage = "{\n" +
"   \"GCM\":\"{" +
"      \\\"data\\\":{" +
"         \\\"title\\\":\\\""+ finalSubject +"\\\"," +
"         \\\"message\\\":\\\""+message+"\\\"" +
"      }," +
"      \\\"time_to_live\\\": 7200" +
"   }\"" +
"}";

PublishResult pushResult = SNS
    .publish((new PublishRequest())
    .withMessage(sendMessage)
    .withSubject(finalSubject)
    .withTargetArn(pushClient.endpoint)
    .withMessageStructure("json")
);

This used to work. I just realized that the messaging behaviour has changed. My android 32 device does not show the received message in the notification center anymore. I do get the message when my app is opened.

I went through the docs and saw that

With FCM, you can send two types of messages to clients:

  • Notification messages, sometimes thought of as "display messages." These are handled by the FCM SDK automatically.
  • Data messages, which are handled by the client app.

So I guess that pure data messages are not getting displayed anymore. Thats why I changed my code to:

sendMessage = "{\n" +
"   \"GCM\":\"{" +
"      \\\"notification\\\":{" +
"         \\\"title\\\":\\\""+ finalSubject +"\\\"," +
"         \\\"body\\\":\\\""+ message +"\\\"" +
"      }," +
"      \\\"time_to_live\\\": 7200" +
"   }\"" +
"}";

PublishResult pushResult = SNS
    .publish((new PublishRequest())
    .withMessage(sendMessage)
    .withSubject(finalSubject)
    .withTargetArn(pushClient.endpoint)
    .withMessageStructure("json")
);

which sadly didn't change anything, but messages in my app are not getting any data anymore. Having data and notification within the message results in the same issue.

This doc actually shows the same message structure as mine. Still no luck. Even the http docs didn't say anything helping me.

0 Answers
Related