Difference between messages an push notifications

Hello,

It’s not clear to me the proper difference between “messages” and “push notifications”.

Our need is creating an App that receives push notifications (background & foreground mode). In order to achieve this goal we…:

  1. …created a Firebase app
  2. …connected properly the Firebase app with the Backendless app via Android server key
  3. …created an app that succesfully subscribe the default channel, and also make succesfully push registration to default channel as well.

Then, we made these tests:

  1. When we send a push notification via Firebase, this is correctly received by the mobile app in both foreground and background modes.
  2. When we send a message via Backendless, it is received correclty in foreground, but it is not shown when it’s running in background
  3. If we send a “push” nortification via backendless, this is ignored by the mobile app despite reading “1 estimated recipient” on backendless

How we have to manage exactly “registration” & “subscription” procedures to enable push notification on a mobile app?

Thanks a lot in advace,

Dan

Hello @Daniele_Di_Gregorio,

The difference is that

Push notifications:

  • can be delivered to your app even if the app is not currently running
  • require registration of the physical device (meaning they cannot be used from a program not running on a device)

Pub/Sub messages:

  • app which receives messages must be running
  • any messages can be send/receive (primitive values, strings, dates, objects, collections)
  • works across all devices, browsers, standalone programs

Please check this documentation for more information about Publish-Subscribe Messaging and Push Notifications.

Regards,
Olha

Hello @olhadanylova,

thanks for your answer. So, we did the following:

  • We’ve created a Firebase App
  • We’ve connected this Firebase app with the backendless app via Android server token
  • We’ve create an Android app that connects with Firebase and get a token, then we use this Firebase token to make a succesfully backendless registration to the default channel (registration verified into “registration” data table)
  • We’ve send a push notification to the mobile app with Firebase: it works properly
  • We’ve send the push notification to the mobile app via Backendless (1 estimated recipient) and it is simply ignored.

Where sould we take a look to fix the problem? It seems everything ok to us…

Thanks

Dan

Hi, @Daniele_Di_Gregorio

You will not be able to receive messages via Backendless as no devices are registered in your app (DeviceRegistration table). You also need to add a Firebase server key in Android Mobile Settings in order to send notifications successfully. For more information on how to configure the Firebase app and what settings you need to make in your Bacendless app, you can read the following section of the documentation:

Push Notification Setup (Android) - Backendless SDK for Android/Java API Documentation

Regards,
Marina

Hi @Marina.Kan,

thanks for your answer. I did everything properly.

I’ve added the firebase server key into Android Mobile Settings
image

My device is correctly registered into DeviceRegistration table:

The push messages sent via Firebase are correctly delivered, the push messages sent via Backendless are ignored

Hello @IMG_s.r.l_Cascina_Garbianotto_2

Can you please provide us with the cURL you use to send the push notification? Or do you do it through the push notification management window in Backendless console?
Also make sure that you are sending the push notification to the “default” channel and in the Android Server Keys the key is added either for all channels or for the “default” channel.
If there is still a problem, please specify your APP ID.

Regards,
Inna

Hello @Inna_Shkolnaya,

I am delivering the Push notification via backendless console. The device is registered in the “default” channel.
image

The android server key is added for all channels:

The notification is sent to “default” channel:

But the notification does not arrive. The app ID is: 6F063A9B-BE36-DD67-FF01-2B0EC55C7600

Thanks a lot

Dan

Hi, @IMG_s.r.l_Cascina_Garbianotto_2

Have you checked the status of the notifications sent? If not, please do so, you can see how to do this in the documentation below. What do you see in the message status? Are there any errors?

https://backendless.com/docs/rest/push_get_message_status_2.html

Regards,
Marina

Hello @Marina.Kan ,

I have no idea where to catch the required to read the message status. I create the push notification on the backendless console, then I send it.

Where can I get the message id?

@IMG_s.r.l_Cascina_Garbianotto_2

You can use the REST API as an example to do this. In the response you will see the messageId. Using the messageId you will be able to check the status.

https://backendless.com/docs/rest/push_example_notification_from_a_push_template.html

Regards,
Marina

Hello @IMG_s.r.l_Cascina_Garbianotto_2

Can we send a test push notification in your app to try and reproduce the problem?

Regards,
Inna

Hello @Inna_Shkolnaya , sure!

@IMG_s.r.l_Cascina_Garbianotto_2

Just checked the push notifications in your app. The status of the message says that it has been sent. I also checked the pushes in my app in the European cluster and everything works.
Try another device (e.g. Android emulator)?
I also recommend you check if the Android Server key is correct. And make sure you generate the right google-services.json file (in case you have multiple projects).

You can check the status of the message as follows:

  • MessageId will be returned after you send the push notification.
  • use this URL: https://eu-api.backendless.com/{{Application ID}}/{{REST API Key}}/messaging/{{MessageId}} to check the message status
    If the push notification was not sent for some reason, the response will contain an error.

Regards,
Inna

Hello @Inna_Shkolnaya , nothing arrives here on my mobile. It’s a real Andoid App (no emulator) so I don’t understand where the problem is. I’ll follow your suggestions carefully once again to check if I missed something and I’ll send a feedback asap.

Thanks of your help
Dan

Hello @Inna_Shkolnaya , I’ve just repeated carefully all the procedure and the Push notification is sent succesfully from the registered device but nothing arrives. Just a doubt: should I activate some kind of listener in order to catch the push notification after registering the device?

  requestData = {
        "deviceToken": fbToken,
        "deviceId": "danPhone",
        "os": "ANDROID",
        "osVersion": "1.0"
    };

    $.ajax({
        url: 'https://eu-api.backendless.com/.........../.........../messaging/registrations',
        type: 'post',
        data: JSON.stringify(requestData),
        contentType: 'application/json',
        dataType: "json",
        async: false,
        success: function (resp) {
            alert(JSON.stringify(resp));
            Backendless.Messaging.pushWithTemplate('Default_channel')
                .then(function (result) {
                    alert(JSON.stringify(result));
                })
                .catch(function (error) {
                    alert(JSON.stringify(error));
                });
        },
        error: function (err) {
            alert(JSON.stringify(requestData));
            alert(JSON.stringify(err));
        }

Dan

Hi, @IMG_s.r.l_Cascina_Garbianotto_2

It is more likely that the issue is with the device registration. Go through the steps of registering your device again. As described in this documentation - Device Registration API - Backendless SDK for JavaScript API Documentation. Try to register another device (e.g. Android emulator). Then try sending messages via rest or any other convenient option. Then check the status of the message (as we recommended above) to see if there are any errors related to receiving (or processing) push notifications.

If you are still unable to identify the cause, can you send us your google-services.json to support@backendless.com? This would let us try using your configuration to see if the issue can be reproduced.

Regards,
Marina

Hello @Marina.Kan , I did everithing carfefully. The device seems to register correctly, I’ve sent a push notification from the app and the response has no error. The push message seems correctly delivered. But I don’t receive the message. I’ll sent the google-services.json file to the support email.

Thanks

Dan

Hello @IMG_s.r.l_Cascina_Garbianotto_2

I am sorry that you have an issue with push notifications.

Let’s try to find more details. What do you get when call get message status Get Message Status - Backendless SDK for JavaScript API Documentation make sure that you use the full message id including the prefix.

Hello Sergey,

here the message status:
image