My React native app (using Expo) is working perfectly fine with Firebase SDK in the Expo Go app. (auth, firestore queries, storage, etc)
But as soon as I build the app as an apk using: "eas build -p android --profile preview", the app installs and opens and crashes on launch - meaning a blank screen appears and the app closes by itself.
After several debugging and builds and trial and errors, I've determined the Firebase SDK is causing the crash. When I removed Firebase npm from my project, the app builds and runs fine, but with Firebase it crashes.
My question is, in a RN Expo app, does the Firebase SDK work properly (versions below) or does react native expo only support the @react-native-firebase library?
I'm using:
- expo: "~52.0.38"
- react: "18.3.1"
- react-native: "0.76.7"
- firebase: "^10.13.1"
My React native app (using Expo) is working perfectly fine with Firebase SDK in the Expo Go app. (auth, firestore queries, storage, etc)
But as soon as I build the app as an apk using: "eas build -p android --profile preview", the app installs and opens and crashes on launch - meaning a blank screen appears and the app closes by itself.
After several debugging and builds and trial and errors, I've determined the Firebase SDK is causing the crash. When I removed Firebase npm from my project, the app builds and runs fine, but with Firebase it crashes.
My question is, in a RN Expo app, does the Firebase SDK work properly (versions below) or does react native expo only support the @react-native-firebase library?
I'm using:
- expo: "~52.0.38"
- react: "18.3.1"
- react-native: "0.76.7"
- firebase: "^10.13.1"
- Please provide the crash trace log. It will help us to figure out what went wrong. – Sally Azulay Commented Mar 12 at 19:32
- there are none! it just crashes on launch and works fine in expo go – Scorpion Edge Commented Mar 12 at 20:17
- I discovered it's an issue with firebase auth (firestore & storage work fine) – Scorpion Edge Commented Mar 12 at 20:20
- Do you need to use firebase auth ? if you do than let me know and I'll help. – Sally Azulay Commented Mar 13 at 9:18
- yes of course i need it – Scorpion Edge Commented Mar 14 at 2:45
1 Answer
Reset to default 0Hope that you'll find your solution here.
If you're using PendingIntent for a notification, update your code as follows:
PendingIntent pendingIntent = PendingIntent.getActivity(
context,
0,
intent,
PendingIntent.FLAG_IMMUTABLE // or PendingIntent.FLAG_MUTABLE if needed
);
If you are using Firebase Cloud Messaging (FCM):
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent intent = new Intent(this, YourActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(
this, 0, intent, PendingIntent.FLAG_IMMUTABLE
);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setContentText(remoteMessage.getNotification().getBody())
.setAutoCancel(true)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
Hope that helps.