Reputation: 19
I integrated the push notification service from "attach" according to the documentation. and the push notification sending is handled via Firebase and Spring-boot for sending the notification.
The push notification is working fine while the application is running. either in the foreground or in the background.
But when the app is closed (or killed) the android system shows an error message "[appName] has stopped" and i have an exception in the logs like this one
[SUB] [91mE/AndroidRuntime(13611): FATAL EXCEPTION: Firebase-Messaging-Intent-Handle[0m
[SUB] [91mE/AndroidRuntime(13611): Process: XXX.XXXX.XXXXXXX, PID: 13611[0m
[SUB] [91mE/AndroidRuntime(13611): java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process XXX.XXXX.XXXXXXX. Make sure to call FirebaseApp.initializeApp(Context) first.[0m
[SUB] [91mE/AndroidRuntime(13611): at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@19.3.0:184)[0m
[SUB] [91mE/AndroidRuntime(13611): at com.google.firebase.messaging.MessagingAnalytics.logToScion(com.google.firebase:firebase-messaging@@20.3.0:99)[0m
[SUB] [91mE/AndroidRuntime(13611): at com.google.firebase.messaging.MessagingAnalytics.logNotificationReceived(com.google.firebase:firebase-messaging@@20.3.0:2)[0m
[SUB] [91mE/AndroidRuntime(13611): at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging@@20.3.0:34)[0m
[SUB] [91mE/AndroidRuntime(13611): at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging@@20.3.0:27)[0m
[SUB] [91mE/AndroidRuntime(13611): at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging@@20.3.0:17)[0m
[SUB] [91mE/AndroidRuntime(13611): at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(com.google.firebase:firebase-messaging@@20.3.0:43)[0m
[SUB] [91mE/AndroidRuntime(13611): at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(Unknown Source:6)[0m
[SUB] [91mE/AndroidRuntime(13611): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)[0m
[SUB] [91mE/AndroidRuntime(13611): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)[0m
[SUB] [91mE/AndroidRuntime(13611): at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)[0m
[SUB] [91mE/AndroidRuntime(13611): at java.lang.Thread.run(Thread.java:764)
I added the required lines in the AndroidManifset.xml according to the documentation, like that
<manifest
xmlns:android='http://schemas.android.com/apk/res/android'
package='XXX.XXX.XXXXXX' android:versionCode='X'
android:versionName='X.X'>
<supports-screens android:xlargeScreens="true" />
<uses-permission
android:name="android.permission.INTERNET" />
<uses-permission
android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:label='XXXXXX'
android:icon="@mipmap/ic_launcher">
<activity
android:name='com.gluonhq.helloandroid.MainActivity'
android:launchMode="singleTop"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<category android:name='android.intent.category.LAUNCHER' />
<action android:name='android.intent.action.MAIN' />
</intent-filter>
</activity>
<service
android:name="com.gluonhq.helloandroid.PushFcmMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name="com.gluonhq.helloandroid.PushNotificationJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true" />
<activity
android:name="com.gluonhq.helloandroid.PushNotificationActivity"
android:parentActivityName="com.gluonhq.helloandroid.MainActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value="com.gluonhq.helloandroid.MainActivity" />
</activity>
</application>
</manifest>
Do I miss something here ?? I checked the docs from docs.gluonhq.com and the samples and attach's docs, and also charm lib docs but i did not find something i still missing to keep it working !!
I tried to integrate the push notification in JavaFX mobile application according to GluonFX docs and it works but not in all cases
Upvotes: 0
Views: 144
Reputation: 19
I solved the Problem, I downloaded Attach Code, and after a while of trying, I built it successfully locally.
Upgrading the Android service and firebase libs was enough to solve the problem
implementation 'com.google.gms:google-services:4.4.1'
implementation 'com.google.firebase:firebase-messaging:23.4.1'
Upvotes: 0