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

Android Notifications : Fix Firebase messaging importation for React Native 0.71 and above - Closes #73 #79

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/intercom-react-native/build/withIntercomAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,17 @@ const withIntercomAppBuildGradle = (config, { pushNotifications }) => {
if (pushNotifications) {
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}`);
// In RN 0.71 and beyond, React Native Gradle Plugin is used, so import of firebase has to be adapted
if (config.modResults.contents.includes(anchor)) {
config.modResults.contents = config.modResults.contents.replace(anchor, `${anchor}
${firebaseImp}`);
} else {
const anchorForReactNative071 = `implementation("com.facebook.react:react-android")`;
config.modResults.contents = config.modResults.contents.replace(anchorForReactNative071, `${anchorForReactNative071}
${firebaseImp}`);
}
}
const applyPlugin = `apply plugin: 'com.google.gms.google-services'`;
if (!config.modResults.contents.includes(applyPlugin)) {
Expand Down
20 changes: 15 additions & 5 deletions packages/intercom-react-native/src/withIntercomAndroid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,21 @@ export const withIntercomAppBuildGradle: ConfigPlugin<{
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}`
);
// In RN 0.71 and beyond, React Native Gradle Plugin is used, so import of firebase has to be adapted
if (config.modResults.contents.includes(anchor)) {
config.modResults.contents = config.modResults.contents.replace(
anchor,
`${anchor}
${firebaseImp}`
);
} else {
const anchorForReactNative071 = `implementation("com.facebook.react:react-android")`;
config.modResults.contents = config.modResults.contents.replace(
anchorForReactNative071,
`${anchorForReactNative071}
${firebaseImp}`
);
}
}

const applyPlugin = `apply plugin: 'com.google.gms.google-services'`;
Expand Down