-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: Adding support for Firebase Messaging via Expo config plugin. #7362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adding support for Firebase Messaging via Expo config plugin. #7362
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for posting this!
A couple questions - is it possible to go with a no-code solution wherein the standard Expo plugins for adding elements to AndroidManifest.xml are used? I assume those exist? Code here (especially Expo-related code which evolves rapidly) adds a non-trivial maintenance burden so I'd prefer a docs solution vs a code solution
If not, then 2) shouldn't this be in the messaging area? (as opposed to app)
I. To my knowledge, if you do not use Expo bare, you can only modify the AndroidManifest.xml through Expo plugins. I've checked BuildProperties, and it does not provide a way to modify AndroidManifest.xml. II. You've made a good point, and it's something I've considered. There are two reasons why I didn't place this part of the code in the Messaging module:
{
"expo": {
"android": {
"googleServicesFile": "./google-services.json"
},
"ios": {
"googleServicesFile": "./GoogleService-Info.plist"
},
"plugins": [
"@react-native-firebase/app",
"@react-native-firebase/perf",
"@react-native-firebase/crashlytics"
]
}
} If it were added to the Messaging module, it would become: {
"expo": {
"android": {
"googleServicesFile": "./google-services.json"
},
"ios": {
"googleServicesFile": "./GoogleService-Info.plist"
},
"plugins": [
"@react-native-firebase/app",
"@react-native-firebase/perf",
"@react-native-firebase/crashlytics",
"@react-native-firebase/messaging"
]
}
} I think this might increase the cognitive load somewhat, but I'm not sure if what I'm doing is correct. Since you've raised doubts, I think what I did may not be intuitive. Now I have moved the code to the Messaging module. Following your advice, I've noticed that continuing to commit in this PR would pollute the commits, so I've created a new PR. [https://github.com//pull/7369] Have a good day. |
Description
This PR adds support for Firebase Messaging in Expo projects via a config plugin. This is mainly achieved by setting the appropriate keys (
com.google.firebase.messaging.default_notification_icon
andcom.google.firebase.messaging.default_notification_color
) in the AndroidManifest of the Android project during the build stage. The addition of this plugin will automatically enable Firebase Messaging support for developers using@react-native-firebase/messaging
in their Expo projects which have the necessary notification configuration.Displaying notifications correctly on Android requires setting a pure white icon. By default, the system uses the app's own icon as the notification icon, which usually isn't purely white. Therefore, it's necessary to specify a notification icon. If no notification configuration is detected from the Expo configuration, a friendly warning will be printed.
Related issues
Release Summary
Added support for Firebase Messaging in Expo projects via a config plugin.
Checklist
Android
iOS
e2e
tests added or updated inpackages/\*\*/e2e
jest
tests added or updated inpackages/\*\*/__tests__
Test Plan
I created the repo to test the feature.
https://github.com/MonchiLin/firebase-messaging-test-app