Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pinpoint FCM push notification status "Successful" but not received in console/device

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

like image 424
phauwn Avatar asked Oct 21 '19 02:10

phauwn


People also ask

How do I test FCM push notifications?

Send a test notification messageOpen the Notifications composer and select New notification. Enter the message text. Select Send test message. In the field labeled Add an FCM registration token, enter the registration token you obtained in a previous section of this guide.

Can FCM notification on Android overwrite previous one?

It's possible. Two approaches. First is you make use of the collapse_key parameter to set the message as a collapsible message.

How does FCM push notification work?

Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user re-engagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4000 bytes to a client app.

What is difference between APNs and FCM?

APNs needs to be used for push messaging when an application is in the background. Hence, FCM uses APNs to deliver messages when the message contains user visible payload, e.g., body, sound etc. FCM also delivers via APNs when content available is set.


2 Answers

"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!,

like image 171
syumaK Avatar answered Oct 22 '22 00:10

syumaK


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": ""
  }
}```
like image 5
Yuxiao Tan Avatar answered Oct 22 '22 00:10

Yuxiao Tan