From 02ae7d0e2cbd58c7fa5e1607979e69585cdbe87f Mon Sep 17 00:00:00 2001 From: Hyungu Kang | Airen Date: Wed, 25 May 2022 17:54:19 +0900 Subject: [PATCH 1/5] feat(react-native): added maven repository apply script --- packages/react-native/android/build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-native/android/build.gradle b/packages/react-native/android/build.gradle index 3f7582ad9..b1bcec469 100644 --- a/packages/react-native/android/build.gradle +++ b/packages/react-native/android/build.gradle @@ -87,3 +87,10 @@ ReactNative.shared.applyPackageVersion() ReactNative.shared.applyDefaultExcludes() ReactNative.module.applyAndroidVersions() ReactNative.module.applyReactNativeDependency("api") +rootProject.allprojects { + repositories { + maven { + url "$rootDir/../node_modules/@notifee/react-native/android/libs" + } + } +} From 6c3adaae554dd17bc1eee9579e1c698ed6c50c60 Mon Sep 17 00:00:00 2001 From: Hyungu Kang | Airen Date: Wed, 25 May 2022 17:55:42 +0900 Subject: [PATCH 2/5] docs(readme): update android installation --- docs/react-native/docs/installation.md | 29 +------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/docs/react-native/docs/installation.md b/docs/react-native/docs/installation.md index ff4d9bbfd..afce86356 100644 --- a/docs/react-native/docs/installation.md +++ b/docs/react-native/docs/installation.md @@ -19,34 +19,7 @@ yarn add @notifee/react-native ``` -## 2. Android: Add local maven repository - -The Notifee core library is packaged an Android "AAR" file. It is distributed in a "local maven repository" for Android integration. - -You must add this repository to your `android/build.gradle` build script file. - -Open `android/build.gradle` for editing, and add these lines in your `allprojects` `repositories` section: - - -```groovy - -allprojects { - - // ... you may have other items before the "repositories" section, that is fine - - repositories { - - // ... you will already have some local repositories defined ... - - // ADD THIS BLOCK - this is how Notifee finds its Android library: - maven { - url "$rootDir/../node_modules/@notifee/react-native/android/libs" - } - } -} -``` - -## 3. Autolinking with React Native +## 2. Autolinking with React Native Users on React Native 0.60+ automatically have access to "[autolinking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md)", requiring no further manual installation steps. To automatically link the package, rebuild your project: From a78cfbda8de42d3b8b75db6665c182ec6d5ef443 Mon Sep 17 00:00:00 2001 From: bang9 Date: Wed, 25 May 2022 22:43:35 +0900 Subject: [PATCH 3/5] chore(react-native): remove core maven related lines --- packages/react-native/example/android/build.gradle | 1 - .../__snapshots__/androidProjectBuild.test.ts.snap | 1 - .../plugin/__tests__/androidProjectBuild.test.ts | 9 +-------- .../plugin/src/withNotifeeProjectGradlePlugin.ts | 13 +------------ tests_react_native/android/build.gradle | 3 --- 5 files changed, 2 insertions(+), 25 deletions(-) diff --git a/packages/react-native/example/android/build.gradle b/packages/react-native/example/android/build.gradle index e8823cd87..650989507 100644 --- a/packages/react-native/example/android/build.gradle +++ b/packages/react-native/example/android/build.gradle @@ -23,7 +23,6 @@ allprojects { repositories { mavenCentral() mavenLocal() - maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs" } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") diff --git a/packages/react-native/plugin/__tests__/__snapshots__/androidProjectBuild.test.ts.snap b/packages/react-native/plugin/__tests__/__snapshots__/androidProjectBuild.test.ts.snap index 11ba54d21..a27a3970e 100644 --- a/packages/react-native/plugin/__tests__/__snapshots__/androidProjectBuild.test.ts.snap +++ b/packages/react-native/plugin/__tests__/__snapshots__/androidProjectBuild.test.ts.snap @@ -25,7 +25,6 @@ buildscript { allprojects { repositories { mavenLocal() - maven { url \\"$rootDir/../node_modules/@notifee/react-native/android/libs\\" } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url(\\"$rootDir/../node_modules/react-native/android\\") diff --git a/packages/react-native/plugin/__tests__/androidProjectBuild.test.ts b/packages/react-native/plugin/__tests__/androidProjectBuild.test.ts index 845cd6ee5..8afa7958c 100644 --- a/packages/react-native/plugin/__tests__/androidProjectBuild.test.ts +++ b/packages/react-native/plugin/__tests__/androidProjectBuild.test.ts @@ -1,7 +1,7 @@ import fs from 'fs/promises'; import path from 'path'; -import { setCompileSdkVersion, setMavenRepository } from '../src/withNotifeeProjectGradlePlugin'; +import { setCompileSdkVersion } from '../src/withNotifeeProjectGradlePlugin'; const getProjectGradle = () => { return fs.readFile(path.resolve(__dirname, './fixtures/project.build.gradle'), { @@ -16,11 +16,4 @@ describe('[Android] project build.gradle test', () => { expect(newProjectGradle).toContain('compileSdkVersion = 31'); }); - - it('adds custom maven repository to project build.gradle', async () => { - const projectGradle = await getProjectGradle(); - const newProjectGradle = setMavenRepository(projectGradle); - - expect(newProjectGradle).toMatchSnapshot(); - }); }); diff --git a/packages/react-native/plugin/src/withNotifeeProjectGradlePlugin.ts b/packages/react-native/plugin/src/withNotifeeProjectGradlePlugin.ts index daf0e0f9d..733a2ef07 100644 --- a/packages/react-native/plugin/src/withNotifeeProjectGradlePlugin.ts +++ b/packages/react-native/plugin/src/withNotifeeProjectGradlePlugin.ts @@ -11,7 +11,6 @@ const withNotifeeProjectGradlePlugin: ConfigPlugin = config => { } modResults.contents = setCompileSdkVersion(modResults.contents); - modResults.contents = setMavenRepository(modResults.contents); return { modResults, ...subConfig }; }); }; @@ -24,15 +23,5 @@ const setCompileSdkVersion = (buildGradle: string): string => { return buildGradle.replace(/compileSdkVersion = 30/, `compileSdkVersion = 31`); }; -const setMavenRepository = (projectBuildGradle: string): string => { - if (projectBuildGradle.includes('@notifee/react-native/android/libs')) return projectBuildGradle; - - return projectBuildGradle.replace( - /mavenLocal\(\)/, - `mavenLocal() - maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs" }`, - ); -}; - -export { setCompileSdkVersion, setMavenRepository }; +export { setCompileSdkVersion }; export default withNotifeeProjectGradlePlugin; diff --git a/tests_react_native/android/build.gradle b/tests_react_native/android/build.gradle index 1eca01884..06e5519e2 100755 --- a/tests_react_native/android/build.gradle +++ b/tests_react_native/android/build.gradle @@ -36,9 +36,6 @@ allprojects { maven { url "$rootDir/../node_modules/detox/Detox-android" } - maven { - url "$rootDir/../node_modules/@notifee/react-native/android/libs" - } mavenCentral { // We don't want to fetch react-native from Maven Central as there are // older versions over there. From e1eef2dd2d4220e92ea89cf3d7a6d3775dbd62ec Mon Sep 17 00:00:00 2001 From: bang9 Date: Wed, 25 May 2022 22:44:24 +0900 Subject: [PATCH 4/5] fix(example): set compileSdkVersion to 31 --- packages/react-native/example/android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/example/android/build.gradle b/packages/react-native/example/android/build.gradle index 650989507..525377647 100644 --- a/packages/react-native/example/android/build.gradle +++ b/packages/react-native/example/android/build.gradle @@ -4,7 +4,7 @@ buildscript { ext { buildToolsVersion = "30.0.2" minSdkVersion = 21 - compileSdkVersion = 30 + compileSdkVersion = 31 targetSdkVersion = 30 ndkVersion = "21.4.7075529" } From e15d304606f13617e3078ae3887a8b2d1bb744a8 Mon Sep 17 00:00:00 2001 From: bang9 Date: Wed, 25 May 2022 22:47:05 +0900 Subject: [PATCH 5/5] chore: link dependencies to current notifee project --- packages/react-native/example/package.json | 2 +- tests_react_native/ios/Podfile.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-native/example/package.json b/packages/react-native/example/package.json index 987b5abee..49f237e7e 100644 --- a/packages/react-native/example/package.json +++ b/packages/react-native/example/package.json @@ -11,7 +11,7 @@ "postinstall": "cd node_modules/@notifee/react-native && yarn" }, "dependencies": { - "@notifee/react-native": "github:notifee/react-native-notifee", + "@notifee/react-native": "link:../", "react": "17.0.2", "react-native": "0.66.0" }, diff --git a/tests_react_native/ios/Podfile.lock b/tests_react_native/ios/Podfile.lock index afdc95a24..d5b3f1686 100644 --- a/tests_react_native/ios/Podfile.lock +++ b/tests_react_native/ios/Podfile.lock @@ -358,10 +358,10 @@ PODS: - Firebase/Messaging (= 8.12.1) - React-Core - RNFBApp - - RNNotifee (5.0.2): + - RNNotifee (5.2.2): - NotifeeCore - React-Core - - RNNotifeeCore (5.0.2): + - RNNotifeeCore (5.2.2): - NotifeeCore - Yoga (1.14.0) @@ -546,10 +546,10 @@ SPEC CHECKSUMS: ReactCommon: 650e33cde4fb7d36781cd3143f5276da0abb2f96 RNFBApp: 5bae3002117e55f3c9aa0fb38175dd16c8046c90 RNFBMessaging: ae6c40883868cd01fa802395174ec7d61cfa0920 - RNNotifee: 2e77e7e79138950470fdb14a5c3f0d4659499871 - RNNotifeeCore: d5a2d465b7ab75f87067324e823fdfdbc992f0e5 + RNNotifee: e300470c3a2dff82bdc5f904d0fa88de9e3a03ad + RNNotifeeCore: 500d628692336ea9f47b693109c7b53508a788bf Yoga: 90dcd029e45d8a7c1ff059e8b3c6612ff409061a PODFILE CHECKSUM: 7b5b8be1d1de29d123a78ccb5cad509690e4f8d0 -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3