Backendless Versin: 5.2.2
Andoid Version: 8.0.0
I can receive my push notifications as expected, if the app is running or in background. But when I kill the app, the notifications do not appear. In the logs I have found a NullPointerException thrown in the BackendlessFCMService:
java.lang.RuntimeException: Unable to instantiate service com.kewitschka.lovr.messaging.PushMessageService: java.lang.NullPointerException: Attempt to invoke interface method 'int android.content.SharedPreferences.getInt(java.lang.String, int)' on a null object reference
at android.app.ActivityThread.handleCreateService(ActivityThread.java)
at android.app.ActivityThread.access$1800(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int android.content.SharedPreferences.getInt(java.lang.String, int)' on a null object reference
at com.backendless.AndroidBackendlessPrefs.getNotificationIdGeneratorInitValue(Unknown Source)
at com.backendless.Backendless.getNotificationIdGeneratorInitValue(Unknown Source)
at com.backendless.push.BackendlessFCMService.<init>(Unknown Source)
at com.kewitschka.lovr.messaging.PushMessageService.<init>(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java)
at android.app.ActivityThread.handleCreateService(ActivityThread.java)
at android.app.ActivityThread.access$1800(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
manifest.xml
<service android:name=".messaging.PushMessageService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
PushMessageService.java
public class PushMessageService extends BackendlessFCMService {
@Override
public boolean onMessage(Context context, Intent intent) {
//some logic
}}
build.gradle
...
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'