Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Android notifications not working - React Native 0.72.5 #73

Open
mckaymichaelis opened this issue Oct 23, 2023 · 2 comments · May be fixed by #79
Open

Android notifications not working - React Native 0.72.5 #73

mckaymichaelis opened this issue Oct 23, 2023 · 2 comments · May be fixed by #79

Comments

@mckaymichaelis
Copy link

"react-native": "0.72.5",
"expo": "^49.0.0",
"@intercom/intercom-react-native": "4.0.1",
"config-plugin-react-native-intercom": "^1.10.1",

I have been unable to get Android notifications working for Intercom, and finally found the issue today.

In this library's withIntercomAndroid.js, the code for inserting the Firebase implementation in the build.gradle is the following:

const firebaseImp = `implementation 'com.google.firebase:firebase-messaging:23.1.+'`;
if (!config.modResults.contents.includes(firebaseImp)) {
    const anchor = `implementation "com.facebook.react:react-native:+"  // From node_modules`;
    config.modResults.contents = config.modResults.contents.replace(anchor, `${anchor} ${firebaseImp}`);
}`

However, in my generated build.gradle, the

implementation "com.facebook.react:react-native:+"  // From node_modules

line is no where to be found, so the replace fails and the firebase implementation never gets added.

In RN 0.71 and beyond, it seems that React Native Gradle Plugin is being used and instead of the above line, inserts this line in the build.gradle instead:

implementation("com.facebook.react:react-android")

So, if I change the anchor line above to this:

const anchor = `implementation("com.facebook.react:react-android")`;

Then the Firebase implementation gets inserted and notifications work like they should.

What do you guys think would be the best way to fix this? Should we search for either of the anchors and add the firebase line if either are found? Use regex? Just hoping I can avoid forking the repository and hosting it myself :)

Thanks!

@mckaymichaelis
Copy link
Author

Any update here?

TomBerriot pushed a commit to TomBerriot/config-plugin-react-native-intercom that referenced this issue Feb 22, 2024
…Native 0.71 and above - Closes cmaycumber#73

Fix Android Notifications issue cmaycumber#73
TomBerriot pushed a commit to TomBerriot/config-plugin-react-native-intercom that referenced this issue Feb 22, 2024
…Native 0.71 and above - Closes cmaycumber#73

Fix Android Notifications issue cmaycumber#73
@TomBerriot
Copy link

TomBerriot commented Feb 22, 2024

Hello 👋 :) I've submitted a PR to be tested handling both cases for support of previous versions too

But as we build on Bitrise I'm wondering how to test, so if you can validate my PR works on your side too it would be appreciated :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants