10

I've got an android app and I'm trying to send push notifications to it through Amazon Pinpoint.

  • My App is able to receive FCM push notifications sent via Postman with my API key.
  • These notifications appear both on the FCM Console, and on the device.

Then I set up FCM push notifications in pinpoint with the same API key, and tested with their "Test Messaging" tool. enter image description here

  • Test message tool says message was sent succesfully.
  • message does NOT appear on device or in FCM console.
  • I get a similar success response using the pinpoint CLI, or sending it through my RAILS app.
  • APNS messages are working end-to-end with pinpoint for my application.

I get a Success response for FCM messages sent through the test messaging tool, through the CLI and send from my Rails application, but none of them appear in the FCM console, or arrive at the device.

The only thing I have noticed in the setup that doesn't match the documentation is Pinpoint doesn't seem to have anywhere to add a Sender ID, just the API Key. (However, I'm not sure the sender ID is actually necessary since I can send a POST request directly with just the API key and FCM gets it... maybe this is outdated?? )

If for some reason the Sender ID is actually required, where would it be entered?

What else can I do to debug this? enter image description here

phauwn
  • 341
  • 3
  • 15

2 Answers2

23

"My App is able to receive FCM push notifications sent via Postman with my API key & These notifications appear both on the FCM Console, and on the device"

From the above quote, since when testing with FCM (Firebase Cloud Messaging) directly you receive the push notification on your device then I suspect that the issue could be related to either two things i.e PushListener class or push notification message type. Let me explain :

When it comes to FCM Push Notifications, there are two types of message types that are supported i.e either “Data” or ”Notification”. So by default FCM console/SDK sends push notification of type "Notification" message. This type of message is handled by FCM SDK automatically and delivered to the notification tray of the app. While on the other hand, “Data" messages are not handled the FCM SDKs and the clients' need to handle this type of messages.

Amazon Pinpoint, currently by default uses “Data” message type for standard message which means that, the Client app has to implement methods' (e.g implementing a PushListenerClass that ingests the payload and displays the incoming notification in the notification tray ) to process the payload and take action.

Can you confirm whether in your application code you have a PushListener Class ? If not, then you can refer to the following articles which explains in details how to handle FCM Messages (Notification and Data) in Android :

https://www.zoftino.com/android-notification-data-messages-from-app-server-using-firebase-cloud-messaging

https://aws-amplify.github.io/docs/android/push-notifications

If you want to send push notification of type "Notification" then you'll need to use :

  1. RawContent property if using Pinpoint SDK/REST API/CLI.The RawContent property needs to be defined/specified as a JSON-formatted string as illustrated below :

    'RawContent' : '{"notification":{"title":"TEST PUSH NOTIFICATION","body":"Hello, this is a test push notification!"}}', // If you define 'RawContent' here, everything ("message") else in the "MessageConfiguration" will be ignored.
    
  2. RawMessage property if using Pinpoint console as illustrated below where you substitute "data" with "notification" :

enter image description here

Hope that helps!,

aksyuma
  • 2,957
  • 1
  • 15
  • 29
6

The standard message is data message by default when it's sent to firebase. To send a notification, you need to send it as raw message. here's an example for both APNs and Firebase

  "APNSMessage": {
    "aps": {
      "alert": {
        "title": "Hello Apple",
        "subtitle": "Notification test",
        "body": "From Pinpoint"
      }
    }
  },
  "GCMMessage": {
    "notification": {
      "title": "Hello Android",
      "body": "From PinPoint"
    }
  },
  "ADMMessage": {
    "data": {
      "message": ""
    }
  },
  "BaiduMessage": {
    "title": "",
    "description": ""
  }
}```
Yuxiao Tan
  • 81
  • 2