From c04aad576e33dfcfccfd4db5b50982947a4e4e43 Mon Sep 17 00:00:00 2001 From: danielel Date: Thu, 6 Jun 2024 15:49:02 +0300 Subject: [PATCH] fix android test --- babel.config.js | 15 +- example/android/build.gradle | 38 +-- example/android/gradle.properties | 27 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/gradlew | 92 ++++-- example/android/myapplication/build.gradle | 287 ++---------------- .../android/myapplication/proguard-rules.pro | 20 -- .../app/MainApplication.java | 9 +- .../MainApplicationReactNativeHost.java | 116 ------- .../components/MainComponentsRegistry.java | 36 --- ...ApplicationTurboModuleManagerDelegate.java | 48 --- example/android/settings.gradle | 10 +- lib/android/.project | 17 -- lib/android/app/build.gradle | 111 ++++--- lib/android/app/proguard-rules.pro | 20 -- .../notification/PushNotificationTest.java | 2 - lib/android/build.gradle | 23 +- lib/android/gradle.properties | 6 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- lib/src/adapters/NativeEventsReceiver.ts | 4 +- metro.config.js | 16 +- package.json | 24 +- react-native.config.js | 4 +- scripts/test-unit.js | 2 +- 24 files changed, 210 insertions(+), 721 deletions(-) delete mode 100644 example/android/myapplication/proguard-rules.pro delete mode 100644 example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/MainApplicationReactNativeHost.java delete mode 100644 example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/components/MainComponentsRegistry.java delete mode 100644 example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java delete mode 100644 lib/android/.project delete mode 100644 lib/android/app/proguard-rules.pro diff --git a/babel.config.js b/babel.config.js index f25946816..af1668c3a 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,12 +1,3 @@ -module.exports = function (api) { - api && api.cache(false); - return { - presets: [ - 'module:metro-react-native-babel-preset' - ], - plugins: [ - '@babel/plugin-proposal-export-namespace-from', - '@babel/plugin-proposal-export-default-from' - ] - }; -}; +module.exports = { + presets: ['module:@react-native/babel-preset'], +}; \ No newline at end of file diff --git a/example/android/build.gradle b/example/android/build.gradle index 59288b7e9..9377a9994 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,34 +1,24 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { ext { - buildToolsVersion = "31.0.0" - minSdkVersion = 21 - compileSdkVersion = 31 - targetSdkVersion = 31 - - if (System.properties['os.arch'] == "aarch64") { - // For M1 Users we need to use the NDK 24 which added support for aarch64 - ndkVersion = "24.0.8215888" - } else { - // Otherwise we default to the side-by-side NDK version from AGP. - ndkVersion = "21.4.7075529" - } - - kotlinVersion = "1.3.61" - kotlinStdlib = "kotlin-stdlib-jdk8" + kotlinVersion = "1.8.10" + RNNKotlinVersion = kotlinVersion detoxKotlinVersion = kotlinVersion + compileSdkVersion = 34 + buildToolsVersion = "34.0.0" + minSdkVersion = 21 + targetSdkVersion = 34 + ndkVersion = "25.1.8937393" } repositories { google() mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:7.0.4") + classpath("com.android.tools.build:gradle") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") classpath("com.facebook.react:react-native-gradle-plugin") classpath("de.undercouch:gradle-download-task:4.1.2") classpath("com.google.gms:google-services:4.3.3") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") } } @@ -46,6 +36,16 @@ allprojects { } } +subprojects { + afterEvaluate { p -> + if (p.hasProperty('android')) { + android { + buildToolsVersion rootProject.ext.buildToolsVersion + } + } + } +} + task clean(type: Delete) { delete rootProject.buildDir } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index ffe919e4f..adb1a34c6 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -12,24 +12,13 @@ # Default value: -Xmx10248m -XX:MaxPermSize=256m org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX android.enableJetifier=true - -# Version of flipper SDK to use with React Native -FLIPPER_VERSION=0.125.0 - -# Use this property to specify which architecture you want to build. -# You can also override it from the CLI using -# ./gradlew -PreactNativeArchitectures=x86_64 - -reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 -# Use this property to enable support to the new architecture. -# This will allow you to use TurboModules and the Fabric render in -# your application. You should enable this flag either if you want -# to write custom TurboModules/Fabric components OR use libraries that -# are providing them. -newArchEnabled=false \ No newline at end of file +android.jetifier.ignorelist=bcprov +hermesEnabled=true +newArchEnabled=false +FLIPPER_VERSION=0.191.0 \ No newline at end of file diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index f338a8808..7bb2df6ba 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/example/android/gradlew b/example/android/gradlew index 9d82f7891..77564ddb2 100755 --- a/example/android/gradlew +++ b/example/android/gradlew @@ -1,4 +1,20 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## ## @@ -6,20 +22,38 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +64,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,26 +75,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -85,7 +105,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -105,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -150,11 +170,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" \ No newline at end of file diff --git a/example/android/myapplication/build.gradle b/example/android/myapplication/build.gradle index b7b7bcd17..b116ed735 100644 --- a/example/android/myapplication/build.gradle +++ b/example/android/myapplication/build.gradle @@ -1,227 +1,33 @@ apply plugin: "com.android.application" +apply plugin: "org.jetbrains.kotlin.android" +apply plugin: "com.facebook.react" -import com.android.build.OutputFile -import org.apache.tools.ant.taskdefs.condition.Os - -/** - * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets - * and bundleReleaseJsAndAssets). - * These basically call `react-native bundle` with the correct arguments during the Android build - * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the - * bundle directly from the development server. Below you can see all the possible configurations - * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "../../../node_modules/react-native/react.gradle"` line. - * - * project.ext.react = [ - * // the name of the generated asset file containing your JS bundle - * bundleAssetName: "index.android.bundle", - * - * // the entry file for bundle generation. If none specified and - * // "index.android.js" exists, it will be used. Otherwise "index.js" is - * // default. Can be overridden with ENTRY_FILE environment variable. - * entryFile: "index.android.js", - * - * // https://reactnative.dev/docs/performance#enable-the-ram-format - * bundleCommand: "ram-bundle", - * - * // whether to bundle JS and assets in debug mode - * bundleInDebug: false, - * - * // whether to bundle JS and assets in release mode - * bundleInRelease: true, - * - * // whether to bundle JS and assets in another build variant (if configured). - * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants - * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' - * // bundleInFreeDebug: true, - * // bundleInPaidRelease: true, - * // bundleInBeta: true, - * - * // whether to disable dev mode in custom build variants (by default only disabled in release) - * // for example: to disable dev mode in the staging build type (if configured) - * devDisabledInStaging: true, - * // The configuration property can be in the following formats - * // 'devDisabledIn${productFlavor}${buildType}' - * // 'devDisabledIn${buildType}' - * - * // the root of your project, i.e. where "package.json" lives - * root: "../../", - * - * // where to put the JS bundle asset in debug mode - * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", - * - * // where to put the JS bundle asset in release mode - * jsBundleDirRelease: "$buildDir/intermediates/assets/release", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in debug mode - * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in release mode - * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", - * - * // by default the gradle tasks are skipped if none of the JS files or assets change; this means - * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to - * // date; if you have any other folders that you want to ignore for performance reasons (gradle - * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ - * // for example, you might want to remove it from here. - * inputExcludes: ["android/**", "ios/**"], - * - * // override which node gets called and with what additional arguments - * nodeExecutableAndArgs: ["node"], - * - * // supply additional arguments to the packager - * extraPackagerArgs: [] - * ] - */ - -project.ext.react = [ - cliPath : "../../../node_modules/react-native/cli.js", - enableHermes: false, // clean and rebuild if changing -] - -apply from: "../../../node_modules/react-native/react.gradle" - -/** - * Set this to true to create two separate APKs instead of one: - * - An APK that only works on ARM devices - * - An APK that only works on x86 devices - * The advantage is the size of the APK is reduced by about 4MB. - * Upload all the APKs to the Play Store and people will download - * the correct one based on the CPU architecture of their device. - */ -def enableSeparateBuildPerCPUArchitecture = false - -/** - * Run Proguard to shrink the Java bytecode in release builds. - */ -def enableProguardInReleaseBuilds = false +react { + root = file("../../../") + reactNativeDir = file("../../../node_modules/react-native") + codegenDir = file("../../../node_modules/@react-native/codegen") +} -/** - * The preferred build flavor of JavaScriptCore. - * - * For example, to use the international variant, you can use: - * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` - * - * The international variant includes ICU i18n library and necessary data - * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that - * give correct results when using with locales other than en-US. Note that - * this variant is about 6MiB larger per architecture than default. - */ def jscFlavor = 'org.webkit:android-jsc:+' -/** - * Whether to enable the Hermes VM. - * - * This should be set on project.ext.react and that value will be read here. If it is not set - * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode - * and the benefits of using Hermes will therefore be sharply reduced. - */ -def enableHermes = project.ext.react.get("enableHermes", false); - -/** - * Architectures to build native code for. - */ -def reactNativeArchitectures() { - def value = project.getProperties().get("reactNativeArchitectures") - return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] -} - android { - ndkVersion rootProject.ext.ndkVersion + compileSdk rootProject.ext.compileSdkVersion - compileSdkVersion rootProject.ext.compileSdkVersion + namespace "com.wix.reactnativenotifications.app" + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + defaultConfig { applicationId "com.wix.reactnativenotifications.app" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" - buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() - - if (isNewArchitectureEnabled()) { - // We configure the NDK build only if you decide to opt-in for the New Architecture. - externalNativeBuild { - ndkBuild { - arguments "APP_PLATFORM=android-21", - "APP_STL=c++_shared", - "NDK_TOOLCHAIN_VERSION=clang", - "GENERATED_SRC_DIR=$buildDir/generated/source", - "PROJECT_BUILD_DIR=$buildDir", - "REACT_ANDROID_DIR=$rootDir/../../node_modules/react-native/ReactAndroid", - "REACT_ANDROID_BUILD_DIR=$rootDir/../../node_modules/react-native/ReactAndroid/build" - cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1" - cppFlags "-std=c++17" - // Make sure this target name is the same you specify inside the - // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable. - targets "rn_68_appmodules" - // Fix for windows limit on number of character in file paths and in command lines - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - arguments "NDK_APP_SHORT_COMMANDS=true" - } - } - } - if (!enableSeparateBuildPerCPUArchitecture) { - ndk { - abiFilters (*reactNativeArchitectures()) - } - } - } - } - - if (isNewArchitectureEnabled()) { - // We configure the NDK build only if you decide to opt-in for the New Architecture. - externalNativeBuild { - ndkBuild { - path "$projectDir/src/main/jni/Android.mk" - } - } - def reactAndroidProjectDir = project(':ReactAndroid').projectDir - def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) { - dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck") - from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") - into("$buildDir/react-ndk/exported") - } - def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) { - dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck") - from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") - into("$buildDir/react-ndk/exported") - } - afterEvaluate { - // If you wish to add a custom TurboModule or component locally, - // you should uncomment this line. - // preBuild.dependsOn("generateCodegenArtifactsFromSchema") - preDebugBuild.dependsOn(packageReactNdkDebugLibs) - preReleaseBuild.dependsOn(packageReactNdkReleaseLibs) - - // Due to a bug inside AGP, we have to explicitly set a dependency - // between configureNdkBuild* tasks and the preBuild tasks. - // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732 - configureNdkBuildRelease.dependsOn(preReleaseBuild) - configureNdkBuildDebug.dependsOn(preDebugBuild) - reactNativeArchitectures().each { architecture -> - tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure { - dependsOn("preDebugBuild") - } - tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure { - dependsOn("preReleaseBuild") - } - } - } } - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include (*reactNativeArchitectures()) - } - } signingConfigs { debug { storeFile file('debug.keystore') @@ -235,38 +41,13 @@ android { signingConfig signingConfigs.debug } release { - // Caution! In production, you need to generate your own keystore file. - // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.debug - minifyEnabled enableProguardInReleaseBuilds - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - } - } - - // applicationVariants are e.g. debug, release - applicationVariants.all { variant -> - variant.outputs.each { output -> - // For each separate APK per architecture, set a unique version code as described here: - // https://developer.android.com/studio/build/configure-apk-splits.html - // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. - def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] - def abi = output.getFilter(OutputFile.ABI) - if (abi != null) { // null for the universal-debug, universal-release variants - output.versionCodeOverride = - defaultConfig.versionCode * 1000 + versionCodes.get(abi) - } - } } } dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - - //noinspection GradleDynamicVersion - implementation "com.facebook.react:react-native:+" // From node_modules - - implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" + implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' @@ -277,14 +58,8 @@ dependencies { exclude group:'com.squareup.okhttp3', module:'okhttp' } - debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { - exclude group:'com.facebook.flipper' - } - - if (enableHermes) { - def hermesPath = "../../../node_modules/hermes-engine/android/"; - debugImplementation files(hermesPath + "hermes-debug.aar") - releaseImplementation files(hermesPath + "hermes-release.aar") + if (hermesEnabled.toBoolean()) { + implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } @@ -292,34 +67,6 @@ dependencies { implementation project(':react-native-notifications') } -if (isNewArchitectureEnabled()) { - // If new architecture is enabled, we let you build RN from source - // Otherwise we fallback to a prebuilt .aar bundled in the NPM package. - // This will be applied to all the imported transtitive dependency. - configurations.all { - resolutionStrategy.dependencySubstitution { - substitute(module("com.facebook.react:react-native")) - .using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source") - } - } -} - -// Run this once to be able to run the application with BUCK -// puts all compile dependencies into folder libs for BUCK to use -task copyDownloadableDepsToLibs(type: Copy) { - from configurations.implementation - into 'libs' -} - apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) -def isNewArchitectureEnabled() { - // To opt-in for the New Architecture, you can either: - // - Set `newArchEnabled` to true inside the `gradle.properties` file - // - Invoke gradle with `-newArchEnabled=true` - // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` - return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" -} - - apply plugin: 'com.google.gms.google-services' diff --git a/example/android/myapplication/proguard-rules.pro b/example/android/myapplication/proguard-rules.pro deleted file mode 100644 index 57dcf0f7c..000000000 --- a/example/android/myapplication/proguard-rules.pro +++ /dev/null @@ -1,20 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/amitd/Library/Android/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - --keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } --keep class * extends com.facebook.react.bridge.NativeModule { *; } diff --git a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainApplication.java b/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainApplication.java index 0bf26f37d..e989e07d6 100644 --- a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainApplication.java +++ b/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/MainApplication.java @@ -8,7 +8,6 @@ import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.wix.reactnativenotifications.RNNotificationsPackage; -import com.wix.reactnativenotifications.app.newarchitecture.MainApplicationReactNativeHost; import java.util.Arrays; import java.util.List; @@ -41,15 +40,9 @@ protected String getJSMainModuleName() { return "index"; } }; - private final ReactNativeHost mNewArchitectureNativeHost = - new MainApplicationReactNativeHost(this); @Override public ReactNativeHost getReactNativeHost() { - if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { - return mNewArchitectureNativeHost; - } else { - return mReactNativeHost; - } + return mReactNativeHost; } } diff --git a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/MainApplicationReactNativeHost.java b/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/MainApplicationReactNativeHost.java deleted file mode 100644 index 90af51f94..000000000 --- a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/MainApplicationReactNativeHost.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.wix.reactnativenotifications.app.newarchitecture; - -import android.app.Application; -import androidx.annotation.NonNull; -import com.facebook.react.PackageList; -import com.facebook.react.ReactInstanceManager; -import com.facebook.react.ReactNativeHost; -import com.facebook.react.ReactPackage; -import com.facebook.react.ReactPackageTurboModuleManagerDelegate; -import com.facebook.react.bridge.JSIModulePackage; -import com.facebook.react.bridge.JSIModuleProvider; -import com.facebook.react.bridge.JSIModuleSpec; -import com.facebook.react.bridge.JSIModuleType; -import com.facebook.react.bridge.JavaScriptContextHolder; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.UIManager; -import com.facebook.react.fabric.ComponentFactory; -import com.facebook.react.fabric.CoreComponentsRegistry; -import com.facebook.react.fabric.EmptyReactNativeConfig; -import com.facebook.react.fabric.FabricJSIModuleProvider; -import com.facebook.react.uimanager.ViewManagerRegistry; -import com.wix.reactnativenotifications.app.BuildConfig; -import com.wix.reactnativenotifications.app.newarchitecture.components.MainComponentsRegistry; -import com.wix.reactnativenotifications.app.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate; -import java.util.ArrayList; -import java.util.List; - -/** - * A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both - * TurboModule delegates and the Fabric Renderer. - * - *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the - * `newArchEnabled` property). Is ignored otherwise. - */ -public class MainApplicationReactNativeHost extends ReactNativeHost { - public MainApplicationReactNativeHost(Application application) { - super(application); - } - - @Override - public boolean getUseDeveloperSupport() { - return BuildConfig.DEBUG; - } - - @Override - protected List getPackages() { - List packages = new PackageList(this).getPackages(); - // Packages that cannot be autolinked yet can be added manually here, for example: - // packages.add(new MyReactNativePackage()); - // TurboModules must also be loaded here providing a valid TurboReactPackage implementation: - // packages.add(new TurboReactPackage() { ... }); - // If you have custom Fabric Components, their ViewManagers should also be loaded here - // inside a ReactPackage. - return packages; - } - - @Override - protected String getJSMainModuleName() { - return "index"; - } - - @NonNull - @Override - protected ReactPackageTurboModuleManagerDelegate.Builder - getReactPackageTurboModuleManagerDelegateBuilder() { - // Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary - // for the new architecture and to use TurboModules correctly. - return new MainApplicationTurboModuleManagerDelegate.Builder(); - } - - @Override - protected JSIModulePackage getJSIModulePackage() { - return new JSIModulePackage() { - @Override - public List getJSIModules( - final ReactApplicationContext reactApplicationContext, - final JavaScriptContextHolder jsContext) { - final List specs = new ArrayList<>(); - - // Here we provide a new JSIModuleSpec that will be responsible of providing the - // custom Fabric Components. - specs.add( - new JSIModuleSpec() { - @Override - public JSIModuleType getJSIModuleType() { - return JSIModuleType.UIManager; - } - - @Override - public JSIModuleProvider getJSIModuleProvider() { - final ComponentFactory componentFactory = new ComponentFactory(); - CoreComponentsRegistry.register(componentFactory); - - // Here we register a Components Registry. - // The one that is generated with the template contains no components - // and just provides you the one from React Native core. - MainComponentsRegistry.register(componentFactory); - - final ReactInstanceManager reactInstanceManager = getReactInstanceManager(); - - ViewManagerRegistry viewManagerRegistry = - new ViewManagerRegistry( - reactInstanceManager.getOrCreateViewManagers(reactApplicationContext)); - - return new FabricJSIModuleProvider( - reactApplicationContext, - componentFactory, - new EmptyReactNativeConfig(), - viewManagerRegistry); - } - }); - return specs; - } - }; - } -} diff --git a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/components/MainComponentsRegistry.java b/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/components/MainComponentsRegistry.java deleted file mode 100644 index d47da70a7..000000000 --- a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/components/MainComponentsRegistry.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.wix.reactnativenotifications.app.newarchitecture.components; - -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.fabric.ComponentFactory; -import com.facebook.soloader.SoLoader; - -/** - * Class responsible to load the custom Fabric Components. This class has native methods and needs a - * corresponding C++ implementation/header file to work correctly (already placed inside the jni/ - * folder for you). - * - *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the - * `newArchEnabled` property). Is ignored otherwise. - */ -@DoNotStrip -public class MainComponentsRegistry { - static { - SoLoader.loadLibrary("fabricjni"); - } - - @DoNotStrip private final HybridData mHybridData; - - @DoNotStrip - private native HybridData initHybrid(ComponentFactory componentFactory); - - @DoNotStrip - private MainComponentsRegistry(ComponentFactory componentFactory) { - mHybridData = initHybrid(componentFactory); - } - - @DoNotStrip - public static MainComponentsRegistry register(ComponentFactory componentFactory) { - return new MainComponentsRegistry(componentFactory); - } -} diff --git a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java b/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java deleted file mode 100644 index 10f515f94..000000000 --- a/example/android/myapplication/src/main/java/com/wix/reactnativenotifications/app/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.wix.reactnativenotifications.app.newarchitecture.modules; - -import com.facebook.jni.HybridData; -import com.facebook.react.ReactPackage; -import com.facebook.react.ReactPackageTurboModuleManagerDelegate; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.soloader.SoLoader; -import java.util.List; - -/** - * Class responsible to load the TurboModules. This class has native methods and needs a - * corresponding C++ implementation/header file to work correctly (already placed inside the jni/ - * folder for you). - * - *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the - * `newArchEnabled` property). Is ignored otherwise. - */ -public class MainApplicationTurboModuleManagerDelegate - extends ReactPackageTurboModuleManagerDelegate { - - private static volatile boolean sIsSoLibraryLoaded; - - protected MainApplicationTurboModuleManagerDelegate( - ReactApplicationContext reactApplicationContext, List packages) { - super(reactApplicationContext, packages); - } - - protected native HybridData initHybrid(); - - native boolean canCreateTurboModule(String moduleName); - - public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder { - protected MainApplicationTurboModuleManagerDelegate build( - ReactApplicationContext context, List packages) { - return new MainApplicationTurboModuleManagerDelegate(context, packages); - } - } - - @Override - protected synchronized void maybeLoadOtherSoLibraries() { - if (!sIsSoLibraryLoaded) { - // If you change the name of your application .so file in the Android.mk file, - // make sure you update the name here as well. - SoLoader.loadLibrary("rn_68_appmodules"); - sIsSoLibraryLoaded = true; - } - } -} diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 850023eec..ce938a81e 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,12 +1,6 @@ rootProject.name = 'NotificationsExampleApp' apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':myapplication' - -includeBuild('../../node_modules/react-native-gradle-plugin') -if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { - include(":ReactAndroid") - project(":ReactAndroid").projectDir = file('../../node_modules/react-native/ReactAndroid') -} - include ':react-native-notifications' -project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../../lib/android/app') \ No newline at end of file +project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../../lib/android/app') +includeBuild('../../node_modules/@react-native/gradle-plugin') diff --git a/lib/android/.project b/lib/android/.project deleted file mode 100644 index 3964dd3f5..000000000 --- a/lib/android/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - android - Project android created by Buildship. - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/lib/android/app/build.gradle b/lib/android/app/build.gradle index 56dea23bd..02d60250e 100644 --- a/lib/android/app/build.gradle +++ b/lib/android/app/build.gradle @@ -1,6 +1,8 @@ import groovy.json.JsonSlurper +import org.gradle.api.tasks.testing.logging.TestExceptionFormat apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback @@ -19,34 +21,8 @@ def kotlinVersion = safeExtGet('kotlinVersion', DEFAULT_KOTLIN_VERSION) def kotlinStdlib = safeExtGet('kotlinStdlib', DEFAULT_KOTLIN_STDLIB_VERSION) def firebaseVersion = safeExtGet('firebaseVersion', DEFAULT_FIREBASE_MESSAGING_VERSION) -Object findReactNativePackageJson() { - def searchPath = 'node_modules/react-native/package.json' - def projectDir = project.projectDir.toString() + '/' - def rnPackageJsonFile = new File(projectDir + searchPath) - while (!rnPackageJsonFile.exists()) { - searchPath = '../' + searchPath - rnPackageJsonFile = new File(projectDir + searchPath) - } - return rnPackageJsonFile -} - -String resolveFlavor() { - def packageSlurper = new JsonSlurper() - def rnPackageJsonFile = findReactNativePackageJson() - def reactNativePackageJson = packageSlurper.parseText(rnPackageJsonFile.text) - def reactNativeVersion = reactNativePackageJson.version - - List versionComponents = reactNativeVersion.tokenize('.') - - if (versionComponents[1].toInteger() < 60) { - return "reactNative59" - } else { - return "reactNative60" - } -} - - android { + buildToolsVersion = "34.0.0" namespace 'com.wix.reactnativenotifications' compileSdkVersion androidSdkVersion defaultConfig { @@ -59,17 +35,27 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 + if (reactNativeMinorVersion() >= 73) { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } else { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + } + kotlinOptions { + if (reactNativeMinorVersion() >= 73) { + jvmTarget = JavaVersion.VERSION_17 + } else { + jvmTarget = JavaVersion.VERSION_11 + } } - dexOptions { javaMaxHeapSize "4g" } buildTypes { release { minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { debuggable true @@ -96,12 +82,15 @@ android { } testOptions { + unitTests.includeAndroidResources = true unitTests.all { t -> - reports { - html.required.set true - } + maxHeapSize = "4g" testLogging { - events "PASSED", "SKIPPED", "FAILED", "standardOut", "standardError" + events "PASSED", "SKIPPED", "FAILED" + exceptionFormat TestExceptionFormat.FULL + showExceptions true + showCauses true + showStackTraces true } afterSuite { desc, result -> if (!desc.parent) { // will match the outermost suite @@ -109,26 +98,64 @@ android { def repeatLength = output.length() println '\n\n' + ('-' * repeatLength) + '\n' + output + '\n' + ('-' * repeatLength) + '\n' - println "see report at file://${t.reports.html.destination}/index.html" + println "see report at file://${t.reports.html.outputLocation}/index.html" } } } + } +} - unitTests { - includeAndroidResources = true - } +int reactNativeMinorVersion() { + List reactNativeVersionComponents = reactNativeVersionComponents(findReactNativePackageJson()) + reactNativeVersionComponents[1].toInteger() +} + + + +String resolveFlavor() { + def packageSlurper = new JsonSlurper() + def rnPackageJsonFile = findReactNativePackageJson() + def reactNativePackageJson = packageSlurper.parseText(rnPackageJsonFile.text) + def reactNativeVersion = reactNativePackageJson.version + + List versionComponents = reactNativeVersion.tokenize('.') + + if (versionComponents[1].toInteger() < 60) { + return "reactNative59" + } else { + return "reactNative60" } } +List reactNativeVersionComponents(rnPackageJsonFile) { + def packageSlurper = new JsonSlurper() + def reactNativePackageJson = packageSlurper.parseText(rnPackageJsonFile.text) + def reactNativeVersion = reactNativePackageJson.version + + return reactNativeVersion.tokenize('-')[0].tokenize('.') +} + +Object findReactNativePackageJson() { + def searchPath = 'node_modules/react-native/package.json' + def projectDir = project.projectDir.toString() + '/' + def rnPackageJsonFile = new File(projectDir + searchPath) + while (!rnPackageJsonFile.exists()) { + searchPath = '../' + searchPath + rnPackageJsonFile = new File(projectDir + searchPath) + } + return rnPackageJsonFile +} + dependencies { implementation "org.jetbrains.kotlin:$kotlinStdlib:$kotlinVersion" implementation "com.google.firebase:firebase-messaging:$firebaseVersion" + //noinspection GradleDynamicVersion implementation 'com.facebook.react:react-native:+' // tests - testImplementation 'junit:junit:4.12' - testImplementation "org.robolectric:robolectric:4.3" + testImplementation 'junit:junit:4.13.2' + testImplementation "org.robolectric:robolectric:4.7.2" testImplementation "org.assertj:assertj-core:3.8.0" testImplementation "com.squareup.assertj:assertj-android:1.1.1" - testImplementation "org.mockito:mockito-core:2.28.2" + testImplementation "org.mockito:mockito-core:4.0.0" } diff --git a/lib/android/app/proguard-rules.pro b/lib/android/app/proguard-rules.pro deleted file mode 100644 index 57dcf0f7c..000000000 --- a/lib/android/app/proguard-rules.pro +++ /dev/null @@ -1,20 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/amitd/Library/Android/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - --keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } --keep class * extends com.facebook.react.bridge.NativeModule { *; } diff --git a/lib/android/app/src/test/java/com/wix/reactnativenotifications/core/notification/PushNotificationTest.java b/lib/android/app/src/test/java/com/wix/reactnativenotifications/core/notification/PushNotificationTest.java index d8fec928f..d8e207669 100644 --- a/lib/android/app/src/test/java/com/wix/reactnativenotifications/core/notification/PushNotificationTest.java +++ b/lib/android/app/src/test/java/com/wix/reactnativenotifications/core/notification/PushNotificationTest.java @@ -48,8 +48,6 @@ import java.util.ArrayList; import java.util.List; -import edu.emory.mathcs.backport.java.util.Arrays; - @RunWith(RobolectricTestRunner.class) public class PushNotificationTest { diff --git a/lib/android/build.gradle b/lib/android/build.gradle index 5f8df2e7b..fd29d89a6 100644 --- a/lib/android/build.gradle +++ b/lib/android/build.gradle @@ -1,12 +1,10 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -import groovy.json.JsonSlurper buildscript { - ext{ + ext { androidGradlePluginVersion = '4.0.0' - kotlinVersion = "1.3.61" + RNNKotlinVersion = '1.4.31' googleServices = "4.3.3" - androidSdkVersion = 33 } repositories { @@ -18,7 +16,7 @@ buildscript { dependencies { classpath "com.android.tools.build:gradle:$androidGradlePluginVersion" classpath "com.google.gms:google-services:$googleServices" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$RNNKotlinVersion" } } @@ -34,18 +32,3 @@ allprojects { } } } -subprojects { - afterEvaluate { project -> - if ((project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library'))) { - android { - compileSdkVersion rootProject.ext.androidSdkVersion - } - } - if (project.hasProperty('defaultConfig')) { - defaultConfig { - minSdkVersion rootProject.ext.androidMinSdkVersion - targetSdkVersion rootProject.ext.androidSdkVersion - } - } - } -} \ No newline at end of file diff --git a/lib/android/gradle.properties b/lib/android/gradle.properties index 9b2f6b092..bef4b0eaa 100644 --- a/lib/android/gradle.properties +++ b/lib/android/gradle.properties @@ -10,12 +10,12 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -android.useAndroidX=true -android.enableJetifier=true \ No newline at end of file +# android.useAndroidX=true +# android.enableJetifier=true \ No newline at end of file diff --git a/lib/android/gradle/wrapper/gradle-wrapper.properties b/lib/android/gradle/wrapper/gradle-wrapper.properties index a476594fc..6a6b02323 100644 --- a/lib/android/gradle/wrapper/gradle-wrapper.properties +++ b/lib/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/lib/src/adapters/NativeEventsReceiver.ts b/lib/src/adapters/NativeEventsReceiver.ts index 2ddf13ff3..1e83a60e8 100644 --- a/lib/src/adapters/NativeEventsReceiver.ts +++ b/lib/src/adapters/NativeEventsReceiver.ts @@ -1,4 +1,4 @@ -import { NativeModules, NativeEventEmitter, EventEmitter, EmitterSubscription } from 'react-native'; +import { NativeModules, NativeEventEmitter, EmitterSubscription } from 'react-native'; import { Registered, RegistrationError, RegisteredPushKit, NotificationResponse } from '../interfaces/NotificationEvents'; @@ -7,7 +7,7 @@ import { NotificationActionResponse } from '../interfaces/NotificationActionResp import { NotificationFactory } from '../DTO/NotificationFactory'; export class NativeEventsReceiver { - private emitter: EventEmitter; + private emitter; constructor(private readonly notificationFactory: NotificationFactory = new NotificationFactory()) { this.emitter = new NativeEventEmitter(NativeModules.RNEventEmitter); } diff --git a/metro.config.js b/metro.config.js index a0eadb590..79e9639bf 100644 --- a/metro.config.js +++ b/metro.config.js @@ -1,17 +1,13 @@ -module.exports = { +const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); + +const config = { projectRoot: `${__dirname}/example`, watchFolders: [ __dirname, ], resolver: { - sourceExts: ['ts', 'tsx', 'js'] + enableGlobalPackages: true, }, - transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: false, - }, - }) - } }; + +module.exports = mergeConfig(getDefaultConfig(__dirname), config); diff --git a/package.json b/package.json index 22e709834..dc88eb6c2 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "release": "node ./scripts/release", "generate-changelog": "gren changelog", "docusaurus": "npm start --prefix website", - "pod-install": "pod install --project-directory=example/ios" + "pod-install": "cd example/ios && pod install" }, "nativePackage": true, "peerDependencies": { @@ -49,23 +49,25 @@ "react-native": "*" }, "devDependencies": { - "@babel/plugin-proposal-export-default-from": "7.2.0", - "@babel/plugin-proposal-export-namespace-from": "7.2.0", + "@babel/core": "^7.20.0", + "@babel/preset-env": "^7.20.0", + "@babel/runtime": "^7.20.0", + "@react-native/babel-preset": "0.73.21", + "@react-native/eslint-config": "0.73.2", + "@react-native/metro-config": "0.73.5", + "@react-native/typescript-config": "0.73.1", + "@types/react": "^18.2.6", + "@types/react-test-renderer": "^18.0.0", "@types/jest": "^27.0.0", "@types/lodash": "4.14.182", - "@types/react": "^17.0.0", - "@types/react-native": "0.67.6", - "@types/react-test-renderer": "16.9.2", + "@types/react-native": "0.73.0", "babel-eslint": "10.0.3", "detox": "^19.4.2", "github-release-notes": "https://github.com/yogevbd/github-release-notes/tarball/e601b3dba72dcd6cba323c1286ea6dd0c0110b58", "jest": "^27.0.0", "lodash": "4.17.21", - "metro-babel-register": "^0.73.2", - "metro-react-native-babel-preset": "^0.67.0", - "react": "^17.0.0", - "react-autobind": "1.0.6", - "react-native": "^0.68.1", + "react": "^18.2.0", + "react-native": "^0.73.3", "shell-utils": "1.0.10", "ts-mockito": "2.5.0", "tslint": "6.1.3", diff --git a/react-native.config.js b/react-native.config.js index d246b0c85..59e67120e 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -4,14 +4,12 @@ module.exports = { ios: {}, android: { sourceDir: './lib/android/app', + packageImportPath: 'import com.wix.reactnativenotifications.RNNotificationsPackage;', packageInstance: 'new RNNotificationsPackage(reactNativeHost.getApplication())', } }, }, project: { - ios: { - project: './example/ios/NotificationsExampleApp.xcworkspace', - }, android: { sourceDir: './example/android/', }, diff --git a/scripts/test-unit.js b/scripts/test-unit.js index cf90e103b..719d1a463 100644 --- a/scripts/test-unit.js +++ b/scripts/test-unit.js @@ -14,7 +14,7 @@ function run() { function runAndroidUnitTests() { const conf = release ? 'testReactNative60ReleaseUnitTest' : 'testReactNative60DebugUnitTest'; - exec.execSync(`cd lib/android && ./gradlew ${conf}`); + exec.execSync(`cd example/android && ./gradlew ${conf}`); } function runIosUnitTests() {