Android FCM

Hi. I am trying to add push notifications to my app. I have already created the Firebase app but noticed that this guide:

https://backendless.com/documentation/messaging/android/messaging_push_notification_setup_androi.htm

there is a comment that says it is sort of outdated. I have tried to follow it but I do not see any devices in the messaging tab in backendless console. Is there any updated guide for it?

Regards,
Andrés

Found the problem! I needed to add the registration intent to the receiver:

        <receiver
            android:name="com.backendless.push.BackendlessBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            &lt;intent-filter&gt;
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />


                &lt;category android:name=&quot;${applicationId}&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/receiver&gt;

Could you please add that missing line in the official documentation?

Regards,
Andrés

I am not convinced that it is needed for the newer version of the Android SDK. See the discussion at:

Take a look at the docs from google:
https://developers.google.com/cloud-messaging/android/client

Specifically, this part:
http://support.backendless.com/public/attachments/bf7d2f07ca0aee00034e4043dcf7d8ca.jpg</img>

Hi Mark.

You are right about the documentation, but I am testing this on Android 5.0 and, if I remove that line, I don’t see the device registered. I will try to test in a different device to see if I get the same result.

I am also having some problems sending messages from the backendless console. I read this documentation https://backendless.com/documentation/messaging/android/messaging_publish_push_notifications.htm, and I am sending this:

  • In Message Text, I put ‘simple text message’
  • In Headers:“android-ticker-text”:“Sample push text”,“android-content-title”:“Basic content title”,“android-content-text”:“Another context text”
    I got the push in my device but I don’t see anything in the ‘Messages’ tab.

Regards,
Andrés

push notifications do not appear on ‘Messages’ section. There you can see only pub/sub messages

Is there a tab or page in the console where I can see the push notification I sent?

no, if you send only push than it would not be stored anywhere.

Hello,

I have migrated my project from GCM to FCM. I haven’t found the updated documentation of Backendless on this subject so I have some question regarding an issue I am facing:

I am using my own PushService that extends the BackendlessPushService and I need to know how to adapt the Manifest file to take into account my receiver.

In fact, the code was the following with GCM:

<receiver
android:name=".push.PushReceiver"
android:permission=“com.google.android.c2dm.permission.SEND”>
<intent-filter>
<action android:name=“com.google.android.c2dm.intent.RECEIVE” />
<action android:name=“com.google.android.c2dm.intent.REGISTRATION” />
<category android:name=“fr.livelovecite” />
</intent-filter>
</receiver>

Removing the above causes the app to crash so I have replaced it with the following:
<service
android:name=“com.google.firebase.messaging.FirebaseMessagingService”>
<intent-filter>
<action android:name=“com.google.firebase.MESSAGING_EVENT”/>
</intent-filter>
</service>
<service
android:name=“com.backendless.push.BackendlessFCMService”>
<intent-filter>
<action android:name=“com.google.firebase.INSTANCE_ID_EVENT”/>
</intent-filter>
</service>
<service android:name=“fr.livelovecite.push.PushService”
android:permission=“android.permission.BIND_JOB_SERVICE”
android:exported=“false”>
</service>

No more crashes but the notification does not appear.

Thank you for your help.
Ralph.

Hi Ralph
Here is a doc for FCM https://backendless.com/docs/android/push_push_notification_setup_androi.html

Hi Vladimir,
Thank you for your prompt reply.

In the documentation com.backendless.push.BackendlessFCMService is declared as the service but nothing for com.backendless.push.BackendlessService. The app is crashing with the following stack:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: fr.livelovecite, PID: 13319
java.lang.IllegalStateException: A reference to BackendlessPushService is missing in AndroidManifest.xml. Make sure to add to the manifest file.Alternatively, if you have a custom push service implementation, make sure your class inherits from"com.backendless.push.BackendlessPushService" and is registered in the manifest fileas
at com.backendless.push.BackendlessPushService.getPushServiceClassName(BackendlessPushService.java:120)
at com.backendless.push.BackendlessPushService.enqueueWork(BackendlessPushService.java:133)
at com.backendless.push.FCMRegistration$1$1.onComplete(FCMRegistration.java:57)
at com.google.android.gms.tasks.zzj.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

What version of sdk do you use?

The latest is 5.2.1
https://mvnrepository.com/artifact/com.backendless/backendless/5.2.1

I am using the 5.2.0.

Found the solution, adding:
<service android:name=".push.PushService"
android:permission=“android.permission.BIND_JOB_SERVICE”
android:exported=“false”>
</service>

resolves the issue of my custom service.

Nonetheless, processed notifications by BackendlessPushService override the sound of android by ignoring the sound state ( Ring, Vibrate, Silent). This means that even when on silent, received push notifications have sounds.

Firstly, please upgrade version to 5.2.1, because it has fixes for FCM.
Secondary, for FCM you shouldn’t use any service except from the documentation one.

point 2:
<service android:name=“com.backendless.push.BackendlessFCMService”>
<intent-filter> <action android:name=“com.google.firebase.MESSAGING_EVENT” /> </intent-filter> </service>

And the last one, use methods registerDevice() and unregisterDevice() intended for FCM (no for GCM)

1 Like

Oleg,

SDK 5.2.1 resolves the issues. I can now extend BackendlessFCMService and declare my own Service in the manifest.

The only remaining problem is the one related to the notification sound, but that’s only a detail.

Thank you for your help !!
Ralph :slight_smile:

Hi Ralph!

Regarding the sound problem you are facing - please create a separate topic and describe your use case in details. I’ll try to help you out with this

Anton

Hi Anton,

here’s the created ticket:

Thank you for your help!