wix / react-native-notifications

React Native Notifications
MIT License
3.25k stars 764 forks source link

[ISSUE?] Default FirebaseApp is not initialized #947

Closed JohnPilar closed 1 year ago

JohnPilar commented 1 year ago

Whenever I use this library, my app suddenly crashes for no reason, upon further inspection using logcat, I was able to trace this problem:

APP LOGCAT:

Process: com.mobileinterface, PID: 11299

02-23 07:47:25.984 11299 11324 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.mobileinterface. Make sure to call FirebaseApp.initializeApp(Context) first.

02-23 07:47:26.003   525  1130 W ActivityTaskManager:   Force finishing activity com.mobileinterface/.MainActivity

02-23 07:47:26.277   525   576 I WindowManager: WIN DEATH: Window{619918e u0 com.mobileinterface/com.mobileinterface.MainActivity}

I was able to fix this by creating a temporary firebase account and adding the google-services.json file inside android/app folder, BUT, we intend not to use firebase as our notifications service. Any help on how to solve this? Is there any setting that I need to disable? Thanks

belics99 commented 1 year ago

I have something similar, I'm using just local notifications, and I didn't add any of Firebase stuff, there is no log about this, I got this log while uploading the app to google console:

Exception java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done (AsyncTask.java:415) at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:381) at java.util.concurrent.FutureTask.setException (FutureTask.java:250) at java.util.concurrent.FutureTask.run (FutureTask.java:269) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637) at java.lang.Thread.run (Thread.java:1012) Caused by java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.app.name Make sure to call FirebaseApp.initializeApp(Context) first. at com.google.firebase.FirebaseApp.getInstance (FirebaseApp.java:183) at com.google.firebase.messaging.FirebaseMessaging.getInstance (com.google.firebase:firebase-messaging@@21.1.0:1) at com.wix.reactnativenotifications.fcm.FcmToken.refreshToken (FcmToken.java:75) at com.wix.reactnativenotifications.fcm.FcmToken.onAppReady (FcmToken.java:65) at com.wix.reactnativenotifications.fcm.FcmInstanceIdRefreshHandlerService.onHandleWork (FcmInstanceIdRefreshHandlerService.java:26) at androidx.core.app.JobIntentService$CommandProcessor.doInBackground (JobIntentService.java:396) at androidx.core.app.JobIntentService$CommandProcessor.doInBackground (JobIntentService.java:387) at android.os.AsyncTask$3.call (AsyncTask.java:394) at java.util.concurrent.FutureTask.run (FutureTask.java:264)

JohnPilar commented 1 year ago

Ended up using this library instead. https://github.com/zo0r/react-native-push-notification

If anyone's interested in figuring the problem out, it has something to do with request permissions.

carlosriveroib commented 1 year ago

I have the same issue? any help

mrnams commented 8 months ago

Facing same issue in .net 8.0 vs 2022

kjahandel commented 8 months ago

I don't use firebase or google services, but I get this error message when starting my app: By the way, I use locale push notification

Aqemu-system-x86_64

4:34

Default FirebaseApp is not initialized in this process com.client. Make sure to call FirebaseApp.initializeApp(Context) first. Here are all the npm packages that I use in the project: { "name": "client", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@react-native-async-storage/async-storage": "^1.22.1", "@react-native-community/push-notification-ios": "^1.11.0", "@react-navigation/bottom-tabs": "^6.5.12", "@react-navigation/native": "^6.1.10", "@react-navigation/native-stack": "^6.9.18", "axios": "^1.6.7", "react": "18.2.0", "react-native": "0.73.4", "react-native-calendars": "^1.1304.1", "react-native-document-picker": "^9.1.1", "react-native-fs": "^2.20.0", "react-native-image-picker": "^7.1.0", "react-native-localize": "^3.0.6", "react-native-media-controls": "^2.3.0", "react-native-permissions": "^4.1.4", "react-native-push-notification": "^8.1.1", "react-native-safe-area-context": "^4.9.0", "react-native-screens": "^3.29.0", "react-native-slider": "^0.11.0", "react-native-vector-icons": "^10.0.3", "react-native-video": "^5.2.1", "react-native-video-thumbnails": "^0.0.0" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/babel-preset": "0.73.21", "@react-native/eslint-config": "0.73.2", "@react-native/metro-config": "0.73.5", "@react-native/typescript-config": "0.73.1", "@types/react": "^18.2.6", "@types/react-native-push-notification": "^8.1.4", "@types/react-native-vector-icons": "^6.4.18", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", "eslint": "^8.19.0", "jest": "^29.6.3", "prettier": "2.8.8", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }, "engines": { "node": ">=18" } }

zhe1ka commented 6 months ago

any solutions?

fjerbi commented 3 months ago

facing the same issue!

jorgegvallejo commented 1 month ago

Bumping up the google services seemed to have worked for me:

android/build.gradle

dependencies {
  ...
  classpath 'com.google.gms:google-services:4.3.15'
}