From 96405cf4546cc46bd8c22c26538bf6ab50d2cebb Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 13:55:13 -0600 Subject: [PATCH 01/25] 3.2.1-beta.2 --- android/build.gradle | 87 ++---- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../com/nami/reactlibrary/NamiBridgeModule.kt | 2 +- .../NamiPaywallManagerBridgeModule.kt | 2 +- examples/Basic/android/app/build.gradle | 257 +++++----------- examples/Basic/android/app/proguard-rules.pro | 5 + .../android/app/src/main/AndroidManifest.xml | 3 +- .../namiml/demo/basic/MainApplication.java | 31 +- examples/Basic/android/build.gradle | 40 +-- examples/Basic/android/gradle.properties | 19 +- .../gradle/wrapper/gradle-wrapper.properties | 8 +- examples/Basic/android/gradlew | 287 +++++++++++------- examples/Basic/android/settings.gradle | 3 +- examples/Basic/config/index.ts | 4 +- examples/Basic/containers/CampaignScreen.tsx | 12 +- examples/Basic/metro.config.js | 21 +- .../nami_launch_context_custom_object.json | 1 + examples/Basic/package.json | 56 ++-- examples/TestNamiTV/android/app/build.gradle | 211 ++++--------- .../android/app/src/main/AndroidManifest.xml | 3 +- .../namiml/demo/basic/MainApplication.java | 29 -- examples/TestNamiTV/android/build.gradle | 44 +-- examples/TestNamiTV/android/gradle.properties | 18 +- .../gradle/wrapper/gradle-wrapper.properties | 8 +- examples/TestNamiTV/android/gradlew | 287 +++++++++++------- examples/TestNamiTV/android/settings.gradle | 1 + examples/TestNamiTV/metro.config.js | 21 +- examples/TestNamiTV/package.json | 54 ++-- .../patches/hash-unary-function.patch | 2 +- ios/Nami.m | 2 +- ios/NamiPaywallManagerBridge.swift | 4 +- package.json | 6 +- react-native-nami-sdk.podspec | 2 +- 33 files changed, 671 insertions(+), 861 deletions(-) create mode 100644 examples/Basic/nami_launch_context_custom_object.json diff --git a/android/build.gradle b/android/build.gradle index 016d0340..9abcc007 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,3 @@ -import groovy.json.JsonSlurper - // android/build.gradle // based on: // @@ -10,7 +8,7 @@ import groovy.json.JsonSlurper // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle // original location: // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle -def DEFAULT_BUILD_TOOLS_VERSION = '30.0.2' +def DEFAULT_BUILD_TOOLS_VERSION = '34.0.0' def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } @@ -18,7 +16,7 @@ apply plugin: 'com.android.library' // apply plugin: 'maven' apply plugin: "kotlin-android" buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.8.20' // The Android Gradle plugin is only required when opening the android folder stand-alone. // This avoids unnecessary downloads and potential conflicts when the library is included as a // module dependency in an application project. @@ -29,13 +27,13 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } } android { - compileSdkVersion 33 + compileSdkVersion 34 buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) defaultConfig { minSdkVersion 22 @@ -44,28 +42,32 @@ android { versionName "1.0" } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 coreLibraryDesugaringEnabled true } lintOptions { abortOnError false } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() - } - dexOptions { - javaMaxHeapSize "4g" - } buildFeatures { viewBinding true } + + flavorDimensions "store" + productFlavors { + amazon { + dimension "store" + } + + play { + dimension "store" + } + } } repositories { mavenCentral() // ref: https://www.baeldung.com/maven-local-repository mavenLocal() maven { url("https://packages.namiml.com/NamiSDK/Amazon/") } + maven { url("https://packages.namiml.com/NamiSDK/Android/") } maven { url 'https://jitpack.io' } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm @@ -83,35 +85,12 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'com.github.jeziellago:compose-markdown:0.3.0' - compileOnly "com.namiml:sdk-amazon:3.2.0-beta.01" + playImplementation "com.namiml:sdk-android:3.2.1-beta.02" + amazonImplementation "com.namiml:sdk-amazon:3.2.1-beta.02" - implementation 'com.facebook.react:react-native:+' // From node_modules + implementation "com.facebook.react:react-native:+" // From node_modules coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" -} -def configureReactNativePom(def pom) { - def packageJson = new JsonSlurper().parseText(file('../package.json').text) - pom.project { - name packageJson.title - artifactId packageJson.name - version = packageJson.version - group = "com.nami.reactlibrary" - description packageJson.description - url packageJson.repository.baseUrl - licenses { - license { - name packageJson.license - url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename - distribution 'repo' - } - } - developers { - developer { - id packageJson.author.username - name packageJson.author.name - } - } - } + } configurations { @@ -121,22 +100,6 @@ configurations { afterEvaluate { project -> // some Gradle build hooks ref: // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html - task androidJavadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += files(android.bootClasspath) -// classpath += files(project.getConfigurations().getByName('compile').asList()) -// classpath += files(project.getConfigurations().getByName('customConfig').asList()) - include '**/*.java' - } - task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { - classifier = 'javadoc' - from androidJavadoc.destinationDir - } - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.srcDirs - include '**/*.java' - } android.libraryVariants.all { variant -> def name = variant.name.capitalize() def javaCompileTask = variant.javaCompileProvider.get() @@ -144,16 +107,8 @@ afterEvaluate { project -> from javaCompileTask.destinationDir } } - artifacts { - archives androidSourcesJar - archives androidJavadocJar - } + task installArchives(type: Upload) { configuration = configurations.archives - // repositories.mavenDeployer { - // // Deploy to react-native-event-bridge/maven, ready to publish to npm - // repository url: "file://${projectDir}/../android/maven" - // configureReactNativePom pom - // } } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index c21f511c..47d110b9 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Wed May 26 17:12:26 EDT 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt index fd34ecab..a232b101 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt @@ -106,7 +106,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) : } else { Arguments.createArray() } - val settingsList = mutableListOf("extendedClientInfo:react-native:3.2.0") + val settingsList = mutableListOf("extendedClientInfo:react-native:3.2.1-beta.2") namiCommandsReact?.toArrayList()?.filterIsInstance()?.let { commandsFromReact -> settingsList.addAll(commandsFromReact) } diff --git a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt index a7ec426f..f13b5df6 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt @@ -227,7 +227,7 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) : @ReactMethod fun setAppSuppliedVideoDetails(url: String, name: String?) { - // To be implemented + NamiPaywallManager.setAppSuppliedVideoDetails(url = url, name = name) } @ReactMethod diff --git a/examples/Basic/android/app/build.gradle b/examples/Basic/android/app/build.gradle index 4c5ad0a3..2638f040 100644 --- a/examples/Basic/android/app/build.gradle +++ b/examples/Basic/android/app/build.gradle @@ -1,95 +1,55 @@ apply plugin: "com.android.application" - -import com.android.build.OutputFile +apply plugin: "org.jetbrains.kotlin.android" +apply plugin: "com.facebook.react" /** - * 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 - * entryFile: "index.android.js", - * - * // https://facebook.github.io/react-native/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: [] - * ] + * This is the configuration block to customize your React Native Android app. + * By default you don't need to apply any configuration, just uncomment the lines you need. */ - -project.ext.react = [ - 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 +react { + /* Folders */ + // The root of your project, i.e. where "package.json" lives. Default is '..' + // root = file("../") + // The folder where the react-native NPM package is. Default is ../node_modules/react-native + // reactNativeDir = file("../node_modules/react-native") + // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen + // codegenDir = file("../node_modules/@react-native/codegen") + // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js + // cliFile = file("../node_modules/react-native/cli.js") + + /* Variants */ + // The list of variants to that are debuggable. For those we're going to + // skip the bundling of the JS bundle and the assets. By default is just 'debug'. + // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. + // debuggableVariants = ["liteDebug", "prodDebug"] + + /* Bundling */ + // A list containing the node command and its flags. Default is just 'node'. + // nodeExecutableAndArgs = ["node"] + // + // The command to run when bundling. By default is 'bundle' + // bundleCommand = "ram-bundle" + // + // The path to the CLI configuration file. Default is empty. + // bundleConfig = file(../rn-cli.config.js) + // + // The name of the generated asset file containing your JS bundle + // bundleAssetName = "MyApplication.android.bundle" + // + // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' + // entryFile = file("../js/MyApplication.android.js") + // + // A list of extra flags to pass to the 'bundle' commands. + // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle + // extraPackagerArgs = [] + + /* Hermes Commands */ + // The hermes compiler command to run. By default it is 'hermesc' + // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" + // + // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" + // hermesFlags = ["-O", "-output-source-map"] +} /** * Run Proguard to shrink the Java bytecode in release builds. @@ -109,66 +69,25 @@ def enableProguardInReleaseBuilds = false */ def jscFlavor = 'org.webkit:android-jsc:+' -/** - * Whether to enable the Hermes VM. - * - * This should be set on project.ext.react and mirrored 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); - android { - compileSdkVersion 33 + compileSdk rootProject.ext.compileSdkVersion - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + namespace = "com.namiml.demo.basic" - lintOptions { - checkReleaseBuilds false + compileOptions { + coreLibraryDesugaringEnabled true } defaultConfig { applicationId "com.namiml.stg.testreactnative" - minSdkVersion 26 - targetSdkVersion 33 versionCode 1 versionName "1.0" testBuildType System.getProperty('testBuildType', 'debug') testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' missingDimensionStrategy 'store', 'play' - } - flavorDimensions "default" - productFlavors { - production { - applicationId "com.namiml.testreact.prod" - minSdkVersion 26 - targetSdkVersion 33 - manifestPlaceholders.app_name = "TestRNProd" - manifestPlaceholders.app_icon = "@mipmap/ic_launcher_prod" - manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round_prod" - } - staging { - applicationId "com.namiml.stg.testreactnative" - minSdkVersion 26 - targetSdkVersion 33 - manifestPlaceholders.app_name = "TestRNStg" - manifestPlaceholders.app_icon = "@mipmap/ic_launcher" - manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round" - } - } - dexOptions { - javaMaxHeapSize "4g" - } - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" - } + multiDexEnabled true + targetSdk rootProject.ext.targetSdkVersion + minSdkVersion rootProject.ext.minSdkVersion } signingConfigs { debug { @@ -185,64 +104,48 @@ android { v2SigningEnabled true } } + flavorDimensions += "environment" + productFlavors { + production { + applicationId "com.namiml.testreact.prod" + manifestPlaceholders.app_name = "TestRNProd" + manifestPlaceholders.app_icon = "@mipmap/ic_launcher_prod" + manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round_prod" + dimension = "environment" + } + staging { + applicationId "com.namiml.stg.testreactnative" + manifestPlaceholders.app_name = "TestRNStg" + manifestPlaceholders.app_icon = "@mipmap/ic_launcher" + manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round" + dimension = "environment" + } + } + buildTypes { debug { signingConfig signingConfigs.debug } release { - // Caution! In production, you need to generate your own keystore file. - // see https://facebook.github.io/react-native/docs/signed-apk-android. - signingConfig null - minifyEnabled true - shrinkResources = true - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.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) - } + signingConfig signingConfigs.release + minifyEnabled enableProguardInReleaseBuilds } } } dependencies { androidTestImplementation('com.wix:detox:+') - implementation ("androidx.appcompat:appcompat:1.3.1") { - version { - strictly '1.3.1' - } - } - implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "com.facebook.react:react-native:+" // From node_modules - implementation 'com.github.jeziellago:compose-markdown:0.3.0' - implementation "com.namiml:sdk-android:3.2.0-beta.01" - implementation project(':react-native-screens') + // The version of react-native is set by the React Native Gradle Plugin + implementation("com.facebook.react:react-android") - 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 } -} -// 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' + coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) diff --git a/examples/Basic/android/app/proguard-rules.pro b/examples/Basic/android/app/proguard-rules.pro index 11b02572..5ae6b4be 100644 --- a/examples/Basic/android/app/proguard-rules.pro +++ b/examples/Basic/android/app/proguard-rules.pro @@ -8,3 +8,8 @@ # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: + +#ParametrizedType ClassCastException error fix +-keep,allowobfuscation,allowshrinking interface retrofit2.Call +-keep,allowobfuscation,allowshrinking class retrofit2.Response +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation diff --git a/examples/Basic/android/app/src/main/AndroidManifest.xml b/examples/Basic/android/app/src/main/AndroidManifest.xml index e1e00f48..0d0b78f1 100644 --- a/examples/Basic/android/app/src/main/AndroidManifest.xml +++ b/examples/Basic/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + getPackages() { List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); - packages.add(new com.swmansion.rnscreens.RNScreensPackage()); +// packages.add(new com.swmansion.rnscreens.RNScreensPackage()); packages.add(new RNConfigPackage()); return packages; } @@ -46,32 +44,5 @@ public ReactNativeHost getReactNativeHost() { public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); - initializeFlipper(this); // Remove this line if you don't want Flipper enabled - } - - /** - * Loads Flipper in React Native templates. - * - * @param context - */ - private static void initializeFlipper(Context context) { - if (BuildConfig.DEBUG) { - try { - /* - We use reflection here to pick up the class that initializes Flipper, - since Flipper library is not available in release mode - */ - Class aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper"); - aClass.getMethod("initializeFlipper", Context.class).invoke(null, context); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } } } diff --git a/examples/Basic/android/build.gradle b/examples/Basic/android/build.gradle index 99eb18c0..7448bf8d 100644 --- a/examples/Basic/android/build.gradle +++ b/examples/Basic/android/build.gradle @@ -2,12 +2,11 @@ buildscript { ext { - buildToolsVersion = "29.0.3" + buildToolsVersion = "34.0.0" minSdkVersion = 22 - compileSdkVersion = 33 + compileSdkVersion = 34 targetSdkVersion = 33 - //1.7.20 kotlin if need - kotlin_version = '1.6.10' + kotlin_version = '1.8.20' } repositories { @@ -15,40 +14,21 @@ buildscript { jcenter() } dependencies { - classpath('com.android.tools.build:gradle:7.0.4') - - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath("com.android.tools.build:gradle:7.4.2") + classpath("com.facebook.react:react-native-gradle-plugin") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") } } -def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) - allprojects { - configurations.all { - resolutionStrategy { - // Remove this override in 0.65+, as a proper fix is included in react-native itself. - force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION - } - } repositories { mavenLocal() - maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url("$rootDir/../node_modules/react-native/android") - } - maven { - // Android JSC is installed from npm - url("$rootDir/../node_modules/jsc-android/dist") - } - google() - jcenter() - maven { - url("$rootDir/../node_modules/detox/Detox-android") - } + mavenCentral() maven { url 'https://jitpack.io' } + maven { url("https://packages.namiml.com/NamiSDK/Amazon/") } maven { url("https://packages.namiml.com/NamiSDK/Android/") } } } + +apply plugin: "com.facebook.react.rootproject" diff --git a/examples/Basic/android/gradle.properties b/examples/Basic/android/gradle.properties index 06ec55ed..54d339c2 100644 --- a/examples/Basic/android/gradle.properties +++ b/examples/Basic/android/gradle.properties @@ -19,8 +19,23 @@ android.useAndroidX=true android.enableJetifier=true -android.enableDexingArtifactTransform=false -org.gradle.jvmargs=-Xmx8192m -XX:MaxPermSize=8192m -XX:+HeapDumpOnOutOfMemoryError +org.gradle.jvmargs=-Xmx8192m -XX:MaxMetaspaceSize=8192m -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureondemand=true + +# 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 + +# Use this property to enable or disable the Hermes JS engine. +# If set to false, you will be using JSC instead. +hermesEnabled=true diff --git a/examples/Basic/android/gradle/wrapper/gradle-wrapper.properties b/examples/Basic/android/gradle/wrapper/gradle-wrapper.properties index 7366f09c..b3cf94ac 100644 --- a/examples/Basic/android/gradle/wrapper/gradle-wrapper.properties +++ b/examples/Basic/android/gradle/wrapper/gradle-wrapper.properties @@ -1,10 +1,10 @@ -#Sun Nov 15 18:57:56 EST 2020 +#Thu Jul 18 13:46:29 MDT 2024 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip -org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true +zipStoreBase=GRADLE_USER_HOME +org.gradle.jvmargs=-Xmx4096m -XX\:MaxPermSize\=4096m -XX\:+HeapDumpOnOutOfMemoryError org.gradle.configureondemand=true diff --git a/examples/Basic/android/gradlew b/examples/Basic/android/gradlew index b0d6d0ab..0adc8e1a 100755 --- a/examples/Basic/android/gradlew +++ b/examples/Basic/android/gradlew @@ -1,13 +1,13 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, @@ -17,78 +17,111 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # 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 +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac 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"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -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 - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -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" +# 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"' -# 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")" +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/examples/Basic/android/settings.gradle b/examples/Basic/android/settings.gradle index 455241e1..e88fa424 100644 --- a/examples/Basic/android/settings.gradle +++ b/examples/Basic/android/settings.gradle @@ -1,5 +1,4 @@ rootProject.name = 'Basic' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' -include ':react-native-screens' -project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android') +includeBuild('../node_modules/@react-native/gradle-plugin') diff --git a/examples/Basic/config/index.ts b/examples/Basic/config/index.ts index 65c31506..d022a9d2 100644 --- a/examples/Basic/config/index.ts +++ b/examples/Basic/config/index.ts @@ -7,8 +7,8 @@ export function getConfigObject() { switch (flavor) { case 'staging': return { - 'appPlatformID-apple': 'APPLE_STG_APP_PLATFORM_ID', - 'appPlatformID-android': 'ANDROID_STG_APP_PLATFORM_ID', + 'appPlatformID-apple': '4a2f6dbf-e684-4d65-a4df-0488771c577d', + 'appPlatformID-android': 'b7232eba-ff1d-4b7f-b8d0-55593b66c1d5', logLevel: 'DEBUG', namiCommands: ['useStagingAPI', 'useNamiWindow'], initialConfig: getInitialConfig(), diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index 216ea2f2..bf5eb68d 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -26,6 +26,7 @@ import { ViewerTabProps } from '../App'; import theme from '../theme'; import { SafeAreaView } from 'react-native-safe-area-context'; import { handleDeepLink } from '../services/deeplinking'; +import customLaunchObject from '../nami_launch_context_custom_object.json'; type CampaignScreenProps = ViewerTabProps<'Campaign'> @@ -90,7 +91,6 @@ const CampaignScreen: FC = ({ navigation }) => { }, []); useEffect(() => { - getAllCampaigns(); const subscriptionSignInRemover = NamiPaywallManager.registerSignInHandler( async () => { console.log('sign in'); @@ -137,6 +137,9 @@ const CampaignScreen: FC = ({ navigation }) => { setCampaigns(availableCampaigns); }, ); + + getAllCampaigns(); + return () => { subscriptionRemover(); subscriptionSignInRemover(); @@ -157,10 +160,12 @@ const CampaignScreen: FC = ({ navigation }) => { const triggerLaunch = (label?: any, url?: any) => { checkIfPaywallOpen(); + NamiPaywallManager.setAppSuppliedVideoDetails('https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', 'app-supplied-video'); + return NamiCampaignManager.launch( label, url, - { customAttributes: {}, customObject: { 'items' : [{ 'name' : 'item1' }] } }, + { customAttributes: {}, customObject: customLaunchObject }, (successAction, error) => { console.log('successAction', successAction); console.log('error', error); @@ -190,9 +195,6 @@ const CampaignScreen: FC = ({ navigation }) => { ? triggerLaunch(item.value, null) : triggerLaunch(null, item.value); } - - NamiPaywallManager.setAppSuppliedVideoDetails('https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', 'app-supplied-video'); - }, []); const onItemPressDefault = useCallback(() => triggerLaunch(null, null), []); diff --git a/examples/Basic/metro.config.js b/examples/Basic/metro.config.js index 40b1ea1e..ad8f87b6 100644 --- a/examples/Basic/metro.config.js +++ b/examples/Basic/metro.config.js @@ -1,16 +1,11 @@ -/* Metro configuration for React Native - * https://github.com/facebook/react-native +const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); + +/** + * Metro configuration + * https://facebook.github.io/metro/docs/configuration * - * @format + * @type {import('metro-config').MetroConfig} */ +const config = {}; -module.exports = { - transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: true, - }, - }), - }, -}; +module.exports = mergeConfig(getDefaultConfig(__dirname), config); diff --git a/examples/Basic/nami_launch_context_custom_object.json b/examples/Basic/nami_launch_context_custom_object.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/examples/Basic/nami_launch_context_custom_object.json @@ -0,0 +1 @@ +{} diff --git a/examples/Basic/package.json b/examples/Basic/package.json index 588bde69..4c98814f 100644 --- a/examples/Basic/package.json +++ b/examples/Basic/package.json @@ -19,42 +19,36 @@ "d": "./scripts/detox.sh" }, "dependencies": { - "@react-native-community/cli-platform-android": "^11.3.1", - "@react-native-community/masked-view": "^0.1.11", - "@react-navigation/bottom-tabs": "^6.5.7", - "@react-navigation/native": "^6.1.6", - "@react-navigation/native-stack": "^6.9.12", - "react": "17.0.2", - "react-native": "0.65.2", - "react-native-gesture-handler": "^1.8.0", + "@react-native-community/cli-platform-android": "^12.3.6", + "@react-native-masked-view/masked-view": "^0.3.1", + "@react-navigation/bottom-tabs": "^6.6.1", + "@react-navigation/native": "^6.1.18", + "@react-navigation/native-stack": "^6.10.1", + "react": "18.2.0", + "react-native": "npm:react-native-tvos@0.73.7-1", "react-native-nami-sdk": "file:../../", - "react-native-reanimated": "^2.14.4", - "react-native-safe-area-context": "^3.3.2", - "react-native-screens": "3.18.2", + "react-native-reanimated": "^3.8.1", + "react-native-safe-area-context": "^4.10.7", + "react-native-screens": "3.30.0", "react-native-iap": "10.1.3" }, "devDependencies": { - "@babel/core": "^7.16.5", - "@babel/runtime": "^7.16.5", - "@react-native-community/eslint-config": "^3.2.0", - "@tsconfig/react-native": "^2.0.3", - "@types/jest": "^29.5.2", - "@types/react": "^18.2.14", - "@types/react-native": "^0.72.2", + "@babel/core": "^7.20.0", + "@babel/preset-env": "^7.20.0", + "@babel/runtime": "^7.20.0", + "@react-native/babel-preset": "^0.73.18", + "@react-native/eslint-config": "^0.73.1", + "@react-native/metro-config": "^0.73.2", + "@react-native/typescript-config": "^0.73.1", + "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", - "@typescript-eslint/eslint-plugin": "^5.57.1", - "@typescript-eslint/parser": "^5.57.1", - "babel-jest": "^27.4.5", - "detox": "20.9.1", - "eslint": "^8.37.0", - "eslint-plugin-react": "^7.32.2", - "eslint-plugin-react-native": "^4.0.0", - "jest": "^29.5.0", - "metro-react-native-babel-preset": "^0.66.2", - "prettier": "^2.8.7", - "react-native-codegen": "^0.0.12", - "react-test-renderer": "17.0.2", - "typescript": "^5.1.6" + "babel-jest": "^29.6.3", + "eslint": "^8.19.0", + "jest": "^29.6.3", + "prettier": "2.8.8", + "react-test-renderer": "18.2.0", + "typescript": "5.0.4", + "detox": "20.9.1" }, "jest": { "preset": "react-native" diff --git a/examples/TestNamiTV/android/app/build.gradle b/examples/TestNamiTV/android/app/build.gradle index acd9a629..cc65c649 100644 --- a/examples/TestNamiTV/android/app/build.gradle +++ b/examples/TestNamiTV/android/app/build.gradle @@ -1,95 +1,55 @@ apply plugin: "com.android.application" - -import com.android.build.OutputFile +apply plugin: "org.jetbrains.kotlin.android" +apply plugin: "com.facebook.react" /** - * 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 - * entryFile: "index.android.js", - * - * // https://facebook.github.io/react-native/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: [] - * ] + * This is the configuration block to customize your React Native Android app. + * By default you don't need to apply any configuration, just uncomment the lines you need. */ - -project.ext.react = [ - 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 +react { + /* Folders */ + // The root of your project, i.e. where "package.json" lives. Default is '..' + // root = file("../") + // The folder where the react-native NPM package is. Default is ../node_modules/react-native + // reactNativeDir = file("../node_modules/react-native") + // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen + // codegenDir = file("../node_modules/@react-native/codegen") + // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js + // cliFile = file("../node_modules/react-native/cli.js") + + /* Variants */ + // The list of variants to that are debuggable. For those we're going to + // skip the bundling of the JS bundle and the assets. By default is just 'debug'. + // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. + // debuggableVariants = ["liteDebug", "prodDebug"] + + /* Bundling */ + // A list containing the node command and its flags. Default is just 'node'. + // nodeExecutableAndArgs = ["node"] + // + // The command to run when bundling. By default is 'bundle' + // bundleCommand = "ram-bundle" + // + // The path to the CLI configuration file. Default is empty. + // bundleConfig = file(../rn-cli.config.js) + // + // The name of the generated asset file containing your JS bundle + // bundleAssetName = "MyApplication.android.bundle" + // + // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' + // entryFile = file("../js/MyApplication.android.js") + // + // A list of extra flags to pass to the 'bundle' commands. + // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle + // extraPackagerArgs = [] + + /* Hermes Commands */ + // The hermes compiler command to run. By default it is 'hermesc' + // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" + // + // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" + // hermesFlags = ["-O", "-output-source-map"] +} /** * Run Proguard to shrink the Java bytecode in release builds. @@ -109,40 +69,32 @@ def enableProguardInReleaseBuilds = false */ def jscFlavor = 'org.webkit:android-jsc:+' -/** - * Whether to enable the Hermes VM. - * - * This should be set on project.ext.react and mirrored 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); - android { - compileSdkVersion 33 + compileSdk rootProject.ext.compileSdkVersion + + namespace = "com.namiml.demo.basic" compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 coreLibraryDesugaringEnabled true } + buildFeatures { + flavorDimensions = ["default", "store"] + } defaultConfig { applicationId "com.namiml.stg.testreactnative" - minSdkVersion 22 - targetSdkVersion 33 versionCode 1 versionName "1.0" manifestPlaceholders.app_name = "TestRNTV" manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round" manifestPlaceholders.app_icon = "@mipmap/ic_launcher" + multiDexEnabled true + targetSdk rootProject.ext.targetSdkVersion + minSdkVersion rootProject.ext.minSdkVersion } - flavorDimensions "default", "store" productFlavors { production { applicationId "com.namiml.testreact.prod" - minSdkVersion 22 - targetSdkVersion 33 dimension "default" manifestPlaceholders.app_name = "RNTVProd" manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round_prod" @@ -150,8 +102,6 @@ android { } staging { applicationId "com.namiml.stg.testreactnative" - minSdkVersion 22 - targetSdkVersion 33 dimension "default" manifestPlaceholders.app_name = "RNTVStg" manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round" @@ -159,17 +109,6 @@ android { } } - dexOptions { - javaMaxHeapSize "4g" - } - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" - } - } signingConfigs { debug { storeFile file('debug.keystore') @@ -205,35 +144,14 @@ android { dimension "store" } } - - // 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"]) - implementation "com.facebook.react:react-native:+" // From node_modules - implementation 'com.github.jeziellago:compose-markdown:0.3.0' - - amazonImplementation "com.namiml:sdk-amazon:3.2.0-beta.01" - playImplementation "com.namiml:sdk-android:3.2.0-beta.01" + // The version of react-native is set by the React Native Gradle Plugin + implementation("com.facebook.react:react-android") - 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 } @@ -241,11 +159,4 @@ dependencies { coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" } -// 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) diff --git a/examples/TestNamiTV/android/app/src/main/AndroidManifest.xml b/examples/TestNamiTV/android/app/src/main/AndroidManifest.xml index 0127605c..099e55be 100644 --- a/examples/TestNamiTV/android/app/src/main/AndroidManifest.xml +++ b/examples/TestNamiTV/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/examples/TestNamiTV/android/app/src/main/java/com/namiml/demo/basic/MainApplication.java b/examples/TestNamiTV/android/app/src/main/java/com/namiml/demo/basic/MainApplication.java index 3a4c6080..03d94408 100644 --- a/examples/TestNamiTV/android/app/src/main/java/com/namiml/demo/basic/MainApplication.java +++ b/examples/TestNamiTV/android/app/src/main/java/com/namiml/demo/basic/MainApplication.java @@ -1,13 +1,11 @@ package com.namiml.demo.basic; import android.app.Application; -import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; -import java.lang.reflect.InvocationTargetException; import java.util.List; import com.namiml.demo.basic.RNConfigPackage; @@ -45,32 +43,5 @@ public ReactNativeHost getReactNativeHost() { public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); - initializeFlipper(this); // Remove this line if you don't want Flipper enabled - } - - /** - * Loads Flipper in React Native templates. - * - * @param context - */ - private static void initializeFlipper(Context context) { - if (BuildConfig.DEBUG) { - try { - /* - We use reflection here to pick up the class that initializes Flipper, - since Flipper library is not available in release mode - */ - Class aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper"); - aClass.getMethod("initializeFlipper", Context.class).invoke(null, context); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } } } diff --git a/examples/TestNamiTV/android/build.gradle b/examples/TestNamiTV/android/build.gradle index cffd3d70..b616262d 100644 --- a/examples/TestNamiTV/android/build.gradle +++ b/examples/TestNamiTV/android/build.gradle @@ -2,52 +2,34 @@ buildscript { ext { - buildToolsVersion = "29.0.3" + buildToolsVersion = "34.0.0" minSdkVersion = 22 - compileSdkVersion = 33 + compileSdkVersion = 34 +// ndkVersion = "25.1.8937393" + kotlin_version = '1.8.20' targetSdkVersion = 33 - kotlin_version = '1.6.10' } repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath('com.android.tools.build:gradle:7.0.4') - - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath("com.android.tools.build:gradle:7.4.2") + classpath("com.facebook.react:react-native-gradle-plugin") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") } } -def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) - allprojects { - configurations.all { - resolutionStrategy { - // Remove this override in 0.65+, as a proper fix is included in react-native itself. - force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION - } - } repositories { mavenLocal() - maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url("$rootDir/../node_modules/react-native/android") - } - maven { - // Android JSC is installed from npm - url("$rootDir/../node_modules/jsc-android/dist") - } - google() - jcenter() + mavenCentral() maven { url 'https://jitpack.io' } - maven { url "https://packages.namiml.com/NamiSDK/Amazon/"} - maven { url "https://packages.namiml.com/NamiSDK/Android/"} - + maven { url("https://packages.namiml.com/NamiSDK/Amazon/") } + maven { url("https://packages.namiml.com/NamiSDK/Android/") } } } + +apply plugin: "com.facebook.react.rootproject" diff --git a/examples/TestNamiTV/android/gradle.properties b/examples/TestNamiTV/android/gradle.properties index c2028f83..54d339c2 100644 --- a/examples/TestNamiTV/android/gradle.properties +++ b/examples/TestNamiTV/android/gradle.properties @@ -19,7 +19,23 @@ android.useAndroidX=true android.enableJetifier=true -org.gradle.jvmargs=-Xmx8192m -XX:MaxPermSize=8192m -XX:+HeapDumpOnOutOfMemoryError +org.gradle.jvmargs=-Xmx8192m -XX:MaxMetaspaceSize=8192m -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureondemand=true + +# 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 + +# Use this property to enable or disable the Hermes JS engine. +# If set to false, you will be using JSC instead. +hermesEnabled=true diff --git a/examples/TestNamiTV/android/gradle/wrapper/gradle-wrapper.properties b/examples/TestNamiTV/android/gradle/wrapper/gradle-wrapper.properties index 7366f09c..b3cf94ac 100644 --- a/examples/TestNamiTV/android/gradle/wrapper/gradle-wrapper.properties +++ b/examples/TestNamiTV/android/gradle/wrapper/gradle-wrapper.properties @@ -1,10 +1,10 @@ -#Sun Nov 15 18:57:56 EST 2020 +#Thu Jul 18 13:46:29 MDT 2024 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip -org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true +zipStoreBase=GRADLE_USER_HOME +org.gradle.jvmargs=-Xmx4096m -XX\:MaxPermSize\=4096m -XX\:+HeapDumpOnOutOfMemoryError org.gradle.configureondemand=true diff --git a/examples/TestNamiTV/android/gradlew b/examples/TestNamiTV/android/gradlew index b0d6d0ab..0adc8e1a 100755 --- a/examples/TestNamiTV/android/gradlew +++ b/examples/TestNamiTV/android/gradlew @@ -1,13 +1,13 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original 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 # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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, @@ -17,78 +17,111 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # 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 +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac 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"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -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 - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -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" +# 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"' -# 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")" +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/examples/TestNamiTV/android/settings.gradle b/examples/TestNamiTV/android/settings.gradle index d8012004..bb2dc9a9 100644 --- a/examples/TestNamiTV/android/settings.gradle +++ b/examples/TestNamiTV/android/settings.gradle @@ -1,3 +1,4 @@ rootProject.name = 'TestNamiTV' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' +includeBuild('../node_modules/@react-native/gradle-plugin') diff --git a/examples/TestNamiTV/metro.config.js b/examples/TestNamiTV/metro.config.js index 40b1ea1e..ad8f87b6 100644 --- a/examples/TestNamiTV/metro.config.js +++ b/examples/TestNamiTV/metro.config.js @@ -1,16 +1,11 @@ -/* Metro configuration for React Native - * https://github.com/facebook/react-native +const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); + +/** + * Metro configuration + * https://facebook.github.io/metro/docs/configuration * - * @format + * @type {import('metro-config').MetroConfig} */ +const config = {}; -module.exports = { - transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: true, - }, - }), - }, -}; +module.exports = mergeConfig(getDefaultConfig(__dirname), config); diff --git a/examples/TestNamiTV/package.json b/examples/TestNamiTV/package.json index c2f830fe..f5ae2c80 100644 --- a/examples/TestNamiTV/package.json +++ b/examples/TestNamiTV/package.json @@ -15,40 +15,34 @@ "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "dependencies": { - "@react-native-community/cli-platform-android": "^11.3.1", - "@react-native-community/masked-view": "^0.1.11", - "@react-navigation/bottom-tabs": "^6.5.7", - "@react-navigation/native": "^6.1.6", - "@react-navigation/native-stack": "^6.9.12", - "react": "18.0.0", - "react-native": "npm:react-native-tvos@0.69.8-2", + "@react-native-community/cli-platform-android": "^12.3.6", + "@react-native-masked-view/masked-view": "^0.3.1", + "@react-navigation/bottom-tabs": "^6.6.1", + "@react-navigation/native": "^6.1.18", + "@react-navigation/native-stack": "^6.10.1", + "react": "18.2.0", + "react-native": "0.73.7-1", "react-native-nami-sdk": "file:../../", - "react-native-reanimated": "^2.3.1", - "react-native-safe-area-context": "^3.3.2", - "react-native-screens": "3.25.0" + "react-native-reanimated": "^3.8.1", + "react-native-safe-area-context": "^4.10.7", + "react-native-screens": "3.30.0" }, "devDependencies": { - "@babel/core": "^7.16.5", - "@babel/runtime": "^7.16.5", - "@react-native-community/eslint-config": "^3.2.0", - "@tsconfig/react-native": "^2.0.3", - "@types/jest": "^29.5.0", - "@types/react": "^18.0.31", - "@types/react-native": "^0.71.5", + "@babel/core": "^7.20.0", + "@babel/preset-env": "^7.20.0", + "@babel/runtime": "^7.20.0", + "@react-native/babel-preset": "^0.73.18", + "@react-native/eslint-config": "^0.73.1", + "@react-native/metro-config": "^0.73.2", + "@react-native/typescript-config": "^0.73.1", + "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", - "@typescript-eslint/eslint-plugin": "^5.57.1", - "@typescript-eslint/parser": "^5.57.1", - "babel-jest": "^27.4.5", - "detox": "20.9.1", - "eslint": "^8.37.0", - "eslint-plugin-react": "^7.32.2", - "eslint-plugin-react-native": "^4.0.0", - "jest": "^29.5.0", - "metro-react-native-babel-preset": "^0.66.2", - "prettier": "^2.8.7", - "react-native-codegen": "^0.0.12", - "react-test-renderer": "17.0.2", - "typescript": "^5.0.2" + "babel-jest": "^29.6.3", + "eslint": "^8.19.0", + "jest": "^29.6.3", + "prettier": "2.8.8", + "react-test-renderer": "18.2.0", + "typescript": "5.0.4" }, "jest": { "preset": "react-native" diff --git a/examples/TestNamiTV/patches/hash-unary-function.patch b/examples/TestNamiTV/patches/hash-unary-function.patch index 2198be0a..3f33c68f 100644 --- a/examples/TestNamiTV/patches/hash-unary-function.patch +++ b/examples/TestNamiTV/patches/hash-unary-function.patch @@ -7,5 +7,5 @@ - struct hash_base : std::unary_function {}; + struct hash_base : std::__unary_function {}; #endif - + struct enable_hash_value { typedef std::size_t type; }; diff --git a/ios/Nami.m b/ios/Nami.m index fe6de961..84e381de 100644 --- a/ios/Nami.m +++ b/ios/Nami.m @@ -50,7 +50,7 @@ @implementation NamiBridge (RCTExternModule) } // Start commands with header iformation for Nami to let them know this is a React client. - NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.2.0"]]; + NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.2.1-beta.2"]]; // Add additional namiCommands app may have sent in. NSObject *appCommandStrings = configDict[@"namiCommands"]; diff --git a/ios/NamiPaywallManagerBridge.swift b/ios/NamiPaywallManagerBridge.swift index 51146acc..e358650e 100644 --- a/ios/NamiPaywallManagerBridge.swift +++ b/ios/NamiPaywallManagerBridge.swift @@ -159,7 +159,7 @@ class RNNamiPaywallManager: RCTEventEmitter { } @objc(setAppSuppliedVideoDetails:name:) - func setAppSuppliedVideoDetails(url _: String, name _: String?) { - // To be implemented + func setAppSuppliedVideoDetails(url: String, name: String?) { + NamiPaywallManager.setAppSuppliedVideoDetails(url, name) } } diff --git a/package.json b/package.json index a390c4c5..390ed4ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nami-sdk", - "version": "3.2.0", + "version": "3.2.1-beta.2", "description": "React Native Module for Nami - Easy subscriptions & in-app purchases, with powerful built-in paywalls and A/B testing.", "main": "index.ts", "types": "index.d.ts", @@ -50,11 +50,11 @@ }, "peerDependencies": { "react": ">=17", - "react-native": ">=0.65" + "react-native": ">=0.73" }, "devDependencies": { "@react-native-community/eslint-config": "^3.2.0", - "@types/react-native": "^0.72.2", + "@types/react-native": "^0.73.0", "@typescript-eslint/eslint-plugin": "^5.59.7", "eslint": "^8.41.0", "eslint-plugin-jest": "^27.2.2", diff --git a/react-native-nami-sdk.podspec b/react-native-nami-sdk.podspec index bfd8d697..fd890ecc 100644 --- a/react-native-nami-sdk.podspec +++ b/react-native-nami-sdk.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,swift}" s.requires_arc = true - s.dependency 'Nami', '3.2.0' + s.dependency 'Nami', '3.2.1-beta.02' s.dependency 'React' end From ad356321691380b1a21995a6857fd8c7b49f8799 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 14:01:00 -0600 Subject: [PATCH 02/25] update github actions --- .github/workflows/CI.yaml | 12 ++++++------ .github/workflows/app_prod.yaml | 6 +++--- .github/workflows/app_stg.yaml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 4a5dcfd1..3a2fab6b 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: 'Checkout ${{ inputs.ref }}' uses: actions/checkout@v3 @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: 'Checkout ${{ inputs.ref }}' uses: actions/checkout@v3 @@ -65,7 +65,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: 'Checkout ${{ inputs.ref }}' uses: actions/checkout@v3 @@ -98,7 +98,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 - name: 'Checkout ${{ inputs.ref }}' uses: actions/checkout@v3 @@ -200,7 +200,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: Cache node_modules uses: actions/cache@v3 @@ -218,7 +218,7 @@ jobs: with: cache: gradle distribution: temurin - java-version: 11 + java-version: 17 - name: Update App Platform ID working-directory: source/examples/Basic/config/ diff --git a/.github/workflows/app_prod.yaml b/.github/workflows/app_prod.yaml index ab761c39..96c6cb12 100644 --- a/.github/workflows/app_prod.yaml +++ b/.github/workflows/app_prod.yaml @@ -32,7 +32,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: 'Checkout ${{ inputs.ref }}' uses: actions/checkout@v2 @@ -114,7 +114,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: "Checkout ${{ inputs.ref }}" uses: actions/checkout@v2 @@ -239,7 +239,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: "Checkout ${{ inputs.ref }}" uses: actions/checkout@v2 diff --git a/.github/workflows/app_stg.yaml b/.github/workflows/app_stg.yaml index 597d3107..44bb42ee 100644 --- a/.github/workflows/app_stg.yaml +++ b/.github/workflows/app_stg.yaml @@ -32,7 +32,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: 'Checkout ${{ inputs.ref }}' uses: actions/checkout@v2 @@ -114,7 +114,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: "Checkout ${{ inputs.ref }}" uses: actions/checkout@v2 @@ -239,7 +239,7 @@ jobs: steps: - uses: actions/setup-node@v3 with: - node-version: "16" + node-version: "18" - name: "Checkout ${{ inputs.ref }}" uses: actions/checkout@v2 From f6f9104eb89479df621becdf1bb0f433d7417757 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 14:10:09 -0600 Subject: [PATCH 03/25] eslint --- examples/Basic/metro.config.js | 3 ++- examples/TestNamiTV/metro.config.js | 3 ++- package.json | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/Basic/metro.config.js b/examples/Basic/metro.config.js index ad8f87b6..bd4a4840 100644 --- a/examples/Basic/metro.config.js +++ b/examples/Basic/metro.config.js @@ -1,4 +1,5 @@ -const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); +/* eslint @typescript-eslint/no-var-requires: "off" */ +const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); /** * Metro configuration diff --git a/examples/TestNamiTV/metro.config.js b/examples/TestNamiTV/metro.config.js index ad8f87b6..bd4a4840 100644 --- a/examples/TestNamiTV/metro.config.js +++ b/examples/TestNamiTV/metro.config.js @@ -1,4 +1,5 @@ -const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); +/* eslint @typescript-eslint/no-var-requires: "off" */ +const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); /** * Metro configuration diff --git a/package.json b/package.json index 390ed4ab..09f96a2d 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ ] }, "peerDependencies": { - "react": ">=17", + "react": ">=18", "react-native": ">=0.73" }, "devDependencies": { @@ -58,10 +58,10 @@ "@typescript-eslint/eslint-plugin": "^5.59.7", "eslint": "^8.41.0", "eslint-plugin-jest": "^27.2.2", - "@types/jest": "^29.5.2", + "@types/jest": "^29.6.3", "prettier": "^2.8.7", - "react": "^17.0.2", - "react-native": "^0.65.2", + "react": "^18.2.0", + "react-native": "^0.73.0", "react-native-codegen": "^0.0.12", "typescript": "^5.0.2" }, From 36ea9ab0d3d88754256afd5c830db43c691457d2 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 14:11:07 -0600 Subject: [PATCH 04/25] jest --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 09f96a2d..29170803 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@typescript-eslint/eslint-plugin": "^5.59.7", "eslint": "^8.41.0", "eslint-plugin-jest": "^27.2.2", - "@types/jest": "^29.6.3", + "@types/jest": "^29.5.2", "prettier": "^2.8.7", "react": "^18.2.0", "react-native": "^0.73.0", From 1ffcf962cb9f916e6e1d9be50591d2441299f123 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 14:15:01 -0600 Subject: [PATCH 05/25] react-native-screens version --- examples/Basic/package.json | 2 +- examples/TestNamiTV/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Basic/package.json b/examples/Basic/package.json index 4c98814f..5276b89b 100644 --- a/examples/Basic/package.json +++ b/examples/Basic/package.json @@ -29,7 +29,7 @@ "react-native-nami-sdk": "file:../../", "react-native-reanimated": "^3.8.1", "react-native-safe-area-context": "^4.10.7", - "react-native-screens": "3.30.0", + "react-native-screens": "3.30.1", "react-native-iap": "10.1.3" }, "devDependencies": { diff --git a/examples/TestNamiTV/package.json b/examples/TestNamiTV/package.json index f5ae2c80..75820936 100644 --- a/examples/TestNamiTV/package.json +++ b/examples/TestNamiTV/package.json @@ -25,7 +25,7 @@ "react-native-nami-sdk": "file:../../", "react-native-reanimated": "^3.8.1", "react-native-safe-area-context": "^4.10.7", - "react-native-screens": "3.30.0" + "react-native-screens": "3.30.1" }, "devDependencies": { "@babel/core": "^7.20.0", From 36379856305a241629b8455bdf481e5b96e4cfc7 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 14:35:53 -0600 Subject: [PATCH 06/25] update dependencies --- examples/Basic/package.json | 13 +++++++------ examples/TestNamiTV/package.json | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/Basic/package.json b/examples/Basic/package.json index 5276b89b..d15ac2b7 100644 --- a/examples/Basic/package.json +++ b/examples/Basic/package.json @@ -20,17 +20,17 @@ }, "dependencies": { "@react-native-community/cli-platform-android": "^12.3.6", - "@react-native-masked-view/masked-view": "^0.3.1", + "@react-native-masked-view/masked-view": "0.3.0", "@react-navigation/bottom-tabs": "^6.6.1", "@react-navigation/native": "^6.1.18", "@react-navigation/native-stack": "^6.10.1", "react": "18.2.0", - "react-native": "npm:react-native-tvos@0.73.7-1", + "react-native": "0.73.7", + "react-native-iap": "10.1.3", "react-native-nami-sdk": "file:../../", "react-native-reanimated": "^3.8.1", "react-native-safe-area-context": "^4.10.7", - "react-native-screens": "3.30.1", - "react-native-iap": "10.1.3" + "react-native-screens": "3.30.1" }, "devDependencies": { "@babel/core": "^7.20.0", @@ -43,12 +43,13 @@ "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", + "detox": "20.9.1", "eslint": "^8.19.0", "jest": "^29.6.3", + "metro-react-native-babel-preset": "^0.77.0", "prettier": "2.8.8", "react-test-renderer": "18.2.0", - "typescript": "5.0.4", - "detox": "20.9.1" + "typescript": "5.0.4" }, "jest": { "preset": "react-native" diff --git a/examples/TestNamiTV/package.json b/examples/TestNamiTV/package.json index 75820936..c37bbd9c 100644 --- a/examples/TestNamiTV/package.json +++ b/examples/TestNamiTV/package.json @@ -21,7 +21,7 @@ "@react-navigation/native": "^6.1.18", "@react-navigation/native-stack": "^6.10.1", "react": "18.2.0", - "react-native": "0.73.7-1", + "react-native": "npm:react-native-tvos@0.73.7-1", "react-native-nami-sdk": "file:../../", "react-native-reanimated": "^3.8.1", "react-native-safe-area-context": "^4.10.7", @@ -38,8 +38,10 @@ "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", + "detox": "20.9.1", "eslint": "^8.19.0", "jest": "^29.6.3", + "metro-react-native-babel-preset": "^0.77.0", "prettier": "2.8.8", "react-test-renderer": "18.2.0", "typescript": "5.0.4" From 9cc3412f657c2b9591b76413d4ca9b1aa1fbbf7e Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 14:54:23 -0600 Subject: [PATCH 07/25] fix signing --- examples/Basic/android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Basic/android/app/build.gradle b/examples/Basic/android/app/build.gradle index 2638f040..a5f28212 100644 --- a/examples/Basic/android/app/build.gradle +++ b/examples/Basic/android/app/build.gradle @@ -127,7 +127,7 @@ android { signingConfig signingConfigs.debug } release { - signingConfig signingConfigs.release + signingConfig null minifyEnabled enableProguardInReleaseBuilds } } From 9e53831e571ae8f32dd71838fbb36d73a0847812 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 16:43:20 -0600 Subject: [PATCH 08/25] align with 3.2.1 --- .../reactlibrary/NamiCampaignManagerBridge.kt | 28 +++++++--- examples/Basic/config/index.ts | 4 +- .../Basic/ios/Basic.xcodeproj/project.pbxproj | 32 ++++++++---- examples/Basic/ios/Basic/AppDelegate.m | 2 +- examples/Basic/ios/Podfile | 15 ------ examples/Basic/ios/PrivacyInfo.xcprivacy | 37 ++++++++++++++ examples/TestNamiTV/ios/Podfile | 1 - .../patches/hash-unary-function.patch | 11 ---- ios/NamiCampaignManagerBridge.swift | 51 +++++++++++++++++-- ios/NamiPaywallManagerBridge.swift | 2 +- src/NamiCampaignManager.ts | 2 + src/types.d.ts | 21 ++++++++ src/types.ts | 22 ++++++++ 13 files changed, 177 insertions(+), 51 deletions(-) create mode 100644 examples/Basic/ios/PrivacyInfo.xcprivacy delete mode 100644 examples/TestNamiTV/patches/hash-unary-function.patch diff --git a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt index 83a83fb4..c830e3c4 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt @@ -28,11 +28,12 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : const val CAMPAIGN_TYPE = "campaignType" const val CAMPAIGN_URL = "campaignUrl" const val PAYWALL_NAME = "paywallName" - const val COMPONENT_CHANGE_ID = "componentChangeId" - const val COMPONENT_CHANGE_NAME = "componentChangeName" + const val COMPONENT_CHANGE = "componentChange" const val SEGMENT_ID = "segmentId" const val EXTERNAL_SEGMENT_ID = "externalSegmentId" const val DEEP_LINK_URL = "deeplinkUrl" + const val TIME_SPENT_ON_PAYWALL = "timeSpentOnPaywall" + const var VIDEO_METADATA = "videoMetadata" const val _RESULT_CAMPAIGN = "ResultCampaign" } @@ -60,6 +61,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : if (context != null) { val productGroups: MutableList = mutableListOf() val customAttributes: MutableMap = mutableMapOf() + val customObject: MutableMap = mutableMapOf() if (context.hasKey("productGroups")) { val groups = context.getArray("productGroups") @@ -86,10 +88,22 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : } } + if (context.hasKey("customObject")) { + val attr = context.getMap("customObject") + if (attr != null) { + val keyIterator = attr.keySetIterator() + while (keyIterator.hasNextKey()) { + val key = keyIterator.nextKey() + customObject[key] = attr.getString(key) ?: "" + } + Log.d(LOG_TAG, "customObject $customObject") + } + } + if (context.hasKey("productGroups")) { - paywallLaunchContext = PaywallLaunchContext(productGroups.toList(), customAttributes) + paywallLaunchContext = PaywallLaunchContext(productGroups.toList(), customAttributes, customObject) } else { - paywallLaunchContext = PaywallLaunchContext(null, customAttributes) + paywallLaunchContext = PaywallLaunchContext(null, customAttributes, customObject) } } @@ -150,11 +164,13 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : putString(CAMPAIGN_TYPE, paywallEvent.campaignType ?: "") putString(CAMPAIGN_URL, paywallEvent.campaignUrl ?: "") putString(PAYWALL_NAME, paywallEvent.paywallName ?: "") - putString(COMPONENT_CHANGE_ID, paywallEvent?.componentChange?.id ?: "") - putString(COMPONENT_CHANGE_NAME, paywallEvent?.componentChange?.name ?: "") + putMap(COMPONENT_CHANGE, paywallEvent?.componentChange ?: Arguments.createMap()) putString(SEGMENT_ID, paywallEvent.segmentId ?: "") putString(EXTERNAL_SEGMENT_ID, paywallEvent.externalSegmentId ?: "") putString(DEEP_LINK_URL, paywallEvent.deeplinkUrl ?: "") + putString(TIME_SPENT_ON_PAYWALL, paywallEvent.timeSpentOnPaywall ?: "") + putMap(VIDEO_METADATA, paywallEvent?.componentChange ?: Arguments.createMap()) + } emitEvent(_RESULT_CAMPAIGN, resultMap) } diff --git a/examples/Basic/config/index.ts b/examples/Basic/config/index.ts index d022a9d2..65c31506 100644 --- a/examples/Basic/config/index.ts +++ b/examples/Basic/config/index.ts @@ -7,8 +7,8 @@ export function getConfigObject() { switch (flavor) { case 'staging': return { - 'appPlatformID-apple': '4a2f6dbf-e684-4d65-a4df-0488771c577d', - 'appPlatformID-android': 'b7232eba-ff1d-4b7f-b8d0-55593b66c1d5', + 'appPlatformID-apple': 'APPLE_STG_APP_PLATFORM_ID', + 'appPlatformID-android': 'ANDROID_STG_APP_PLATFORM_ID', logLevel: 'DEBUG', namiCommands: ['useStagingAPI', 'useNamiWindow'], initialConfig: getInitialConfig(), diff --git a/examples/Basic/ios/Basic.xcodeproj/project.pbxproj b/examples/Basic/ios/Basic.xcodeproj/project.pbxproj index d8996e0f..4e39e5d3 100644 --- a/examples/Basic/ios/Basic.xcodeproj/project.pbxproj +++ b/examples/Basic/ios/Basic.xcodeproj/project.pbxproj @@ -537,11 +537,11 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-BasicProduction/Pods-BasicProduction-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle", + "${PODS_CONFIGURATION_BUILD_DIR}/React-Core/RCTI18nStrings.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle", + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCTI18nStrings.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -577,11 +577,11 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Basic/Pods-Basic-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle", + "${PODS_CONFIGURATION_BUILD_DIR}/React-Core/RCTI18nStrings.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle", + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCTI18nStrings.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -596,12 +596,10 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-BasicProduction/Pods-BasicProduction-frameworks.sh", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Nami/NamiApple.framework/NamiApple", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NamiApple.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -616,12 +614,10 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Basic/Pods-Basic-frameworks.sh", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Nami/NamiApple.framework/NamiApple", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NamiApple.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -1023,7 +1019,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LANGUAGE_STANDARD = "c++20"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; @@ -1069,7 +1065,15 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = "$(inherited)"; + OTHER_CPLUSPLUSFLAGS = "$(inherited)"; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); + REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; + USE_HERMES = false; }; name = Debug; }; @@ -1077,7 +1081,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LANGUAGE_STANDARD = "c++20"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; @@ -1115,7 +1119,15 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; + OTHER_CFLAGS = "$(inherited)"; + OTHER_CPLUSPLUSFLAGS = "$(inherited)"; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); + REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; + USE_HERMES = false; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/examples/Basic/ios/Basic/AppDelegate.m b/examples/Basic/ios/Basic/AppDelegate.m index 567fbf63..cbfbb119 100644 --- a/examples/Basic/ios/Basic/AppDelegate.m +++ b/examples/Basic/ios/Basic/AppDelegate.m @@ -47,7 +47,7 @@ - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull N - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; + return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif diff --git a/examples/Basic/ios/Podfile b/examples/Basic/ios/Podfile index 9157230b..f2cccbb4 100644 --- a/examples/Basic/ios/Podfile +++ b/examples/Basic/ios/Podfile @@ -17,12 +17,6 @@ target 'Basic' do pod 'RNScreens', :path => '../node_modules/react-native-screens' - # Enables Flipper. - # - # Note that if you have use_frameworks! enabled, Flipper will not work and - # you should disable the next line. - use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" }) - use_native_modules! target 'BasicTests' do @@ -43,18 +37,9 @@ target 'BasicProduction' do pod 'RNScreens', :path => '../node_modules/react-native-screens' - # Enables Flipper. - # - # Note that if you have use_frameworks! enabled, Flipper will not work and - # you should disable the next line. - use_flipper!({ "Flipper-DoubleConversion" => "1.1.7" }) - use_native_modules! end post_install do |installer| - react_native_post_install(installer) - #__apply_Xcode_12_5_M1_post_install_workaround(installer) - end diff --git a/examples/Basic/ios/PrivacyInfo.xcprivacy b/examples/Basic/ios/PrivacyInfo.xcprivacy new file mode 100644 index 00000000..41b8317f --- /dev/null +++ b/examples/Basic/ios/PrivacyInfo.xcprivacy @@ -0,0 +1,37 @@ + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA92.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + NSPrivacyCollectedDataTypes + + NSPrivacyTracking + + + diff --git a/examples/TestNamiTV/ios/Podfile b/examples/TestNamiTV/ios/Podfile index 8f18f30e..88553eea 100644 --- a/examples/TestNamiTV/ios/Podfile +++ b/examples/TestNamiTV/ios/Podfile @@ -42,5 +42,4 @@ end post_install do |installer| react_native_post_install(installer) - #__apply_Xcode_12_5_M1_post_install_workaround(installer) end diff --git a/examples/TestNamiTV/patches/hash-unary-function.patch b/examples/TestNamiTV/patches/hash-unary-function.patch deleted file mode 100644 index 3f33c68f..00000000 --- a/examples/TestNamiTV/patches/hash-unary-function.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ../ios/Pods/boost/boost/container_hash/hash.hpp.orig.hpp 2024-07-10 14:24:31 -+++ ../ios/Pods/boost/boost/container_hash/hash.hpp 2024-07-10 14:25:23 -@@ -128,7 +128,7 @@ - }; - #else - template -- struct hash_base : std::unary_function {}; -+ struct hash_base : std::__unary_function {}; - #endif - - struct enable_hash_value { typedef std::size_t type; }; diff --git a/ios/NamiCampaignManagerBridge.swift b/ios/NamiCampaignManagerBridge.swift index 2dee8ec0..b9a4f698 100644 --- a/ios/NamiCampaignManagerBridge.swift +++ b/ios/NamiCampaignManagerBridge.swift @@ -81,6 +81,24 @@ class RNNamiCampaignManager: RCTEventEmitter { actionString = "PAGE_CHANGE" case .slide_change: actionString = "SLIDE_CHANGE" + case .nami_collapsible_drawer_open: + actionString = "COLLAPSIBLE_DRAWER_OPEN" + case .nami_collapsible_drawer_close: + actionString = "COLLAPSIBLE_DRAWER_CLOSE" + case .video_play: + actionString = "VIDEO_STARTED" + case .video_pause: + actionString = "VIDEO_PAUSED" + case .video_resume: + actionString = "VIDEO_RESUMED" + case .video_end: + actionString = "VIDEO_ENDED" + case .video_change: + actionString = "VIDEO_CHANGED" + case .video_mute: + actionString = "VIDEO_MUTED" + case .video_unmute: + actionString = "VIDEO_UNMUTED" default: actionString = "UNKNOWN" } @@ -88,6 +106,26 @@ class RNNamiCampaignManager: RCTEventEmitter { let dictionaries = paywallEvent.purchases.map { purchase in RNNamiPurchaseManager.purchaseToPurchaseDict(purchase) } + var componentChange: [String: Any?] = [:] + + if let eventComponentChange = paywallEvent.componentChange { + componentChange["id"] = eventComponentChange.id + componentChange["name"] = eventComponentChange.name + } + + var videoMetadata: [String: Any?] = [:] + + if let eventVideoMetadata = paywallEvent.videoMetadata { + videoMetadata["id"] = eventVideoMetadata.id + videoMetadata["name"] = eventVideoMetadata.name + videoMetadata["url"] = eventVideoMetadata.name + videoMetadata["loopVideo"] = eventVideoMetadata.loopVideo + videoMetadata["muteByDefault"] = eventVideoMetadata.muteByDefault + videoMetadata["autoplayVideo"] = eventVideoMetadata.autoplayVideo + videoMetadata["contentTimecode"] = eventVideoMetadata.contentTimecode + videoMetadata["contentDuration"] = eventVideoMetadata.contentDuration + } + let payload: [String: Any?] = [ "campaignId": paywallEvent.campaignId, "campaignName": paywallEvent.campaignName, @@ -103,8 +141,9 @@ class RNNamiCampaignManager: RCTEventEmitter { "purchaseError": errorSting, "purchases": dictionaries, "deeplinkUrl": paywallEvent.deeplinkUrl, - "componentChangeId": paywallEvent.componentChange?.id, - "componentChangeName": paywallEvent.componentChange?.name, + "componentChange": componentChange, + "videoMetadata": videoMetadata, + "timeSpentOnPaywall": paywallEvent.timeSpentOnPaywall, ] RNNamiCampaignManager.shared?.sendEvent(withName: "ResultCampaign", body: payload) @@ -126,6 +165,7 @@ class RNNamiCampaignManager: RCTEventEmitter { var productGroups: [String]? var customAttributes: [String: Any]? + var customObject: [String: Any]? if let context = context { if let contextProductGroups = context["productGroups"] as? [String] { @@ -134,10 +174,13 @@ class RNNamiCampaignManager: RCTEventEmitter { if let contextCustomAttributes = context["customAttributes"] as? [String: Any] { customAttributes = contextCustomAttributes } + if let contextCustomObject = context["customObject"] as? [String: Any] { + customObject = contextCustomObject + } } - if productGroups != nil || customAttributes != nil { - paywallLaunchContext = PaywallLaunchContext(productGroups: productGroups, customAttributes: customAttributes) + if productGroups != nil || customAttributes != nil || customObject != nil { + paywallLaunchContext = PaywallLaunchContext(productGroups: productGroups, customAttributes: customAttributes, customObject: customObject) } var launchMethod: (() -> Void)? diff --git a/ios/NamiPaywallManagerBridge.swift b/ios/NamiPaywallManagerBridge.swift index e358650e..65e54cc6 100644 --- a/ios/NamiPaywallManagerBridge.swift +++ b/ios/NamiPaywallManagerBridge.swift @@ -160,6 +160,6 @@ class RNNamiPaywallManager: RCTEventEmitter { @objc(setAppSuppliedVideoDetails:name:) func setAppSuppliedVideoDetails(url: String, name: String?) { - NamiPaywallManager.setAppSuppliedVideoDetails(url, name) + NamiPaywallManager.setAppSuppliedVideoDetails(url: url, name: name) } } diff --git a/src/NamiCampaignManager.ts b/src/NamiCampaignManager.ts index b129ca8b..b578b59b 100644 --- a/src/NamiCampaignManager.ts +++ b/src/NamiCampaignManager.ts @@ -68,6 +68,8 @@ export const NamiCampaignManager: ICampaignManager = { segmentId: body.segmentId, externalSegmentId: body.externalSegmentId, deeplinkUrl: body.deeplinkUrl, + videoMetadata: body.videoMetadata, + timeSpentOnPaywall: body.timeSpentOnPaywall, sku: body.sku, purchaseError: body.purchaseError, purchases: body.purchases, diff --git a/src/types.d.ts b/src/types.d.ts index 547b69f7..1e091d47 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -143,6 +143,15 @@ export declare enum NamiPaywallAction { TOGGLE_CHANGE = "TOGGLE_CHANGE", PAGE_CHANGE = "PAGE_CHANGE", SLIDE_CHANGE = "SLIDE_CHANGE", + COLLAPSIBLE_DRAWER_OPEN = "COLLAPSIBLE_DRAWER_OPEN", + COLLAPSIBLE_DRAWER_CLOSE = "COLLAPSIBLE_DRAWER_CLOSE", + VIDEO_STARTED = "VIDEO_STARTED", + VIDEO_PAUSED = "VIDEO_PAUSED", + VIDEO_RESUMED = "VIDEO_RESUMED", + VIDEO_ENDED = "VIDEO_ENDED", + VIDEO_CHANGED = "VIDEO_CHANGED", + VIDEO_MUTED = "VIDEO_MUTED", + VIDEO_UNMUTED = "VIDEO_UNMUTED", UNKNOWN = "UNKNOWN" } export type NamiPurchase = { @@ -170,9 +179,21 @@ export type NamiPaywallEvent = { sku?: NamiSKU; purchaseError?: string; purchases?: NamiPurchase[]; + videoMetadata?: NamiPaywallEventVideoMetadata; + timeSpentOnPaywall?: number; }; export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void; export type NamiPaywallComponentChange = { id?: string; name?: string; }; +export type NamiPaywallEventVideoMetadata = { + id?: string; + name?: string; + url?: string; + loopVideo: boolean; + muteByDefault: boolean; + autoplayVideo: boolean; + contentTimecode?: number; + contentDuration?: number; +}; diff --git a/src/types.ts b/src/types.ts index 51e2b815..5f241dc9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -278,6 +278,15 @@ export enum NamiPaywallAction { TOGGLE_CHANGE = 'TOGGLE_CHANGE', PAGE_CHANGE = 'PAGE_CHANGE', SLIDE_CHANGE = 'SLIDE_CHANGE', + COLLAPSIBLE_DRAWER_OPEN = 'COLLAPSIBLE_DRAWER_OPEN', + COLLAPSIBLE_DRAWER_CLOSE = 'COLLAPSIBLE_DRAWER_CLOSE', + VIDEO_STARTED = 'VIDEO_STARTED', + VIDEO_PAUSED = 'VIDEO_PAUSED', + VIDEO_RESUMED = 'VIDEO_RESUMED', + VIDEO_ENDED = 'VIDEO_ENDED', + VIDEO_CHANGED = 'VIDEO_CHANGED', + VIDEO_MUTED = 'VIDEO_MUTED', + VIDEO_UNMUTED = 'VIDEO_UNMUTED', UNKNOWN = 'UNKNOWN', } @@ -318,6 +327,8 @@ export type NamiPaywallEvent = { sku?: NamiSKU; purchaseError?: string; purchases?: NamiPurchase[]; + videoMetadata?: NamiPaywallEventVideoMetadata; + timeSpentOnPaywall?: number; }; export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void; @@ -326,3 +337,14 @@ export type NamiPaywallComponentChange = { id?: string; name?: string; }; + +export type NamiPaywallEventVideoMetadata = { + id?: string; + name?: string; + url?: string; + loopVideo: boolean; + muteByDefault: boolean; + autoplayVideo: boolean; + contentTimecode?: number; + contentDuration?: number; +}; From b0d7ef1898caa88353f5fe375f82218226468758 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 16:43:41 -0600 Subject: [PATCH 09/25] remove no longer needed patch --- examples/Basic/patches/yoga-compilation-fix.patch | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 examples/Basic/patches/yoga-compilation-fix.patch diff --git a/examples/Basic/patches/yoga-compilation-fix.patch b/examples/Basic/patches/yoga-compilation-fix.patch deleted file mode 100644 index 68fded17..00000000 --- a/examples/Basic/patches/yoga-compilation-fix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ../node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp.orig 2024-07-10 13:35:29 -+++ ../node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp 2024-07-10 11:54:48 -@@ -2229,7 +2229,7 @@ - depth, - generationCount); - node->setLayoutHadOverflow( -- node->getLayout().hadOverflow() | -+ node->getLayout().hadOverflow() || - currentRelativeChild->getLayout().hadOverflow()); - } - return deltaFreeSpace; From 393839234cc803519a8c9810b9cdcbfc3939fccc Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 17:12:45 -0600 Subject: [PATCH 10/25] fix android compilation --- .../reactlibrary/NamiCampaignManagerBridge.kt | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt index c830e3c4..749fc8b0 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt @@ -33,7 +33,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : const val EXTERNAL_SEGMENT_ID = "externalSegmentId" const val DEEP_LINK_URL = "deeplinkUrl" const val TIME_SPENT_ON_PAYWALL = "timeSpentOnPaywall" - const var VIDEO_METADATA = "videoMetadata" + const val VIDEO_METADATA = "videoMetadata" const val _RESULT_CAMPAIGN = "ResultCampaign" } @@ -164,14 +164,39 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : putString(CAMPAIGN_TYPE, paywallEvent.campaignType ?: "") putString(CAMPAIGN_URL, paywallEvent.campaignUrl ?: "") putString(PAYWALL_NAME, paywallEvent.paywallName ?: "") - putMap(COMPONENT_CHANGE, paywallEvent?.componentChange ?: Arguments.createMap()) putString(SEGMENT_ID, paywallEvent.segmentId ?: "") putString(EXTERNAL_SEGMENT_ID, paywallEvent.externalSegmentId ?: "") putString(DEEP_LINK_URL, paywallEvent.deeplinkUrl ?: "") - putString(TIME_SPENT_ON_PAYWALL, paywallEvent.timeSpentOnPaywall ?: "") - putMap(VIDEO_METADATA, paywallEvent?.componentChange ?: Arguments.createMap()) } + + if (paywallEvent.componentChange != null) { + val componentChangeMap = Arguments.createMap().apply { + putString("id", paywallEvent.componentChange?.id ?: "") + putString("name", paywallEvent.componentChange?.name ?: "") + } + + resultMap.putMap(COMPONENT_CHANGE, componentChangeMap) + } + + if (paywallEvent.videoMetadata != null) { + val videoMetadataMap = Arguments.createMap().apply { + putString("id", paywallEvent.videoMetadata?.id ?: "") + putString("name", paywallEvent.videoMetadata?.name ?: "") + putBoolean("autoplayVideo", paywallEvent.videoMetadata?.autoplayVideo ?: false) + putBoolean("muteByDefault", paywallEvent.videoMetadata?.muteByDefault ?: false) + putBoolean("loopVideo", paywallEvent.videoMetadata?.loopVideo ?: false) + putDouble("contentDuration", paywallEvent.videoMetadata?.contentDuration ?: 0.0) + putDouble("contentTimecode", paywallEvent.videoMetadata?.contentTimecode ?: 0.0) + } + + resultMap.putMap(VIDEO_METADATA, videoMetadataMap) + } + + if (paywallEvent.timeSpentOnPaywall != null) { + resultMap.putDouble(TIME_SPENT_ON_PAYWALL, paywallEvent.timeSpentOnPaywall ?: 0.0) + } + emitEvent(_RESULT_CAMPAIGN, resultMap) } From 9aa1d2d8f93f068a9cf3c6084605712038f1a33b Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 17:56:18 -0600 Subject: [PATCH 11/25] detox --- examples/Basic/android/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/Basic/android/build.gradle b/examples/Basic/android/build.gradle index 7448bf8d..c11d7ee0 100644 --- a/examples/Basic/android/build.gradle +++ b/examples/Basic/android/build.gradle @@ -26,6 +26,9 @@ allprojects { google() mavenCentral() maven { url 'https://jitpack.io' } + maven { + url("$rootDir/../node_modules/detox/Detox-android") + } maven { url("https://packages.namiml.com/NamiSDK/Amazon/") } maven { url("https://packages.namiml.com/NamiSDK/Android/") } } From bf37073525445714902764f8f898f561ab676340 Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Tue, 23 Jul 2024 19:40:26 -0600 Subject: [PATCH 12/25] Update app_stg.yaml --- .github/workflows/app_stg.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/app_stg.yaml b/.github/workflows/app_stg.yaml index 44bb42ee..678221db 100644 --- a/.github/workflows/app_stg.yaml +++ b/.github/workflows/app_stg.yaml @@ -201,10 +201,10 @@ jobs: pod install --repo-update working-directory: source/examples/Basic/ios - - name: Apply Patches - run: | - patch -p0 < *.patch - working-directory: source/examples/Basic/patches + # - name: Apply Patches + # run: | + # patch -p0 < *.patch + # working-directory: source/examples/Basic/patches - name: Build resolve Swift dependencies run: | From c2f99b4f92b9b119eb3718f646714e3f33ffa979 Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Tue, 23 Jul 2024 19:40:54 -0600 Subject: [PATCH 13/25] Update app_stg.yaml --- .github/workflows/app_stg.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/app_stg.yaml b/.github/workflows/app_stg.yaml index 678221db..e8a7c0dc 100644 --- a/.github/workflows/app_stg.yaml +++ b/.github/workflows/app_stg.yaml @@ -326,10 +326,10 @@ jobs: RCT_NEW_ARCH_ENABLED=0 SWIFT_VERSION=5 pod install --repo-update working-directory: source/examples/TestNamiTV/ios - - name: Apply Patches - run: | - patch -p0 < *.patch - working-directory: source/examples/TestNamiTV/patches + # - name: Apply Patches + # run: | + # patch -p0 < *.patch + # working-directory: source/examples/TestNamiTV/patches - name: Build resolve Swift dependencies run: | From 5f4b6917da39d8fb0c163e4eac536ecbb1120323 Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Tue, 23 Jul 2024 19:43:24 -0600 Subject: [PATCH 14/25] Update app_stg.yaml --- .github/workflows/app_stg.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/app_stg.yaml b/.github/workflows/app_stg.yaml index e8a7c0dc..1da5f65f 100644 --- a/.github/workflows/app_stg.yaml +++ b/.github/workflows/app_stg.yaml @@ -34,6 +34,13 @@ jobs: with: node-version: "18" + - name: Setup Java + uses: actions/setup-java@v3 + with: + cache: gradle + distribution: temurin + java-version: 17 + - name: 'Checkout ${{ inputs.ref }}' uses: actions/checkout@v2 with: From 565a1a26fb3d6d543b562de4d7f5f4da197c5dde Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Tue, 23 Jul 2024 20:19:50 -0600 Subject: [PATCH 15/25] Update react-native-nami-sdk.podspec --- react-native-nami-sdk.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-native-nami-sdk.podspec b/react-native-nami-sdk.podspec index fd890ecc..6c07041a 100644 --- a/react-native-nami-sdk.podspec +++ b/react-native-nami-sdk.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,swift}" s.requires_arc = true - s.dependency 'Nami', '3.2.1-beta.02' + s.dependency 'Nami', '3.2.1' s.dependency 'React' end From 3de17f34c4cf4218c01d785020c4d4bfa6aecb41 Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Tue, 23 Jul 2024 21:24:30 -0600 Subject: [PATCH 16/25] Update app_stg.yaml --- .github/workflows/app_stg.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/app_stg.yaml b/.github/workflows/app_stg.yaml index 1da5f65f..9370a8ea 100644 --- a/.github/workflows/app_stg.yaml +++ b/.github/workflows/app_stg.yaml @@ -34,19 +34,19 @@ jobs: with: node-version: "18" - - name: Setup Java - uses: actions/setup-java@v3 - with: - cache: gradle - distribution: temurin - java-version: 17 - - name: 'Checkout ${{ inputs.ref }}' uses: actions/checkout@v2 with: path: source ref: '${{ inputs.ref }}' + - name: Setup Java + uses: actions/setup-java@v3 + with: + cache: gradle + distribution: temurin + java-version: 17 + - name: Install Google API python client run: | pip install google-api-python-client From 9fadd5dbd5ead81edc4880edfbd36fba6ad25b7f Mon Sep 17 00:00:00 2001 From: Dan Burcaw <92536821+namidan@users.noreply.github.com> Date: Tue, 23 Jul 2024 21:24:58 -0600 Subject: [PATCH 17/25] Update app_prod.yaml --- .github/workflows/app_prod.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/app_prod.yaml b/.github/workflows/app_prod.yaml index 96c6cb12..b6266625 100644 --- a/.github/workflows/app_prod.yaml +++ b/.github/workflows/app_prod.yaml @@ -40,6 +40,13 @@ jobs: path: source ref: '${{ inputs.ref }}' + - name: Setup Java + uses: actions/setup-java@v3 + with: + cache: gradle + distribution: temurin + java-version: 17 + - name: Install Google API python client run: | pip install google-api-python-client From 0159cfc87bb1d02c6ecb9850cf48f62f3c2af091 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 22:08:09 -0600 Subject: [PATCH 18/25] add some logging --- examples/Basic/containers/CampaignScreen.tsx | 6 +++++- examples/Basic/package.json | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index bf5eb68d..a9a5fa9c 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -27,6 +27,7 @@ import theme from '../theme'; import { SafeAreaView } from 'react-native-safe-area-context'; import { handleDeepLink } from '../services/deeplinking'; import customLaunchObject from '../nami_launch_context_custom_object.json'; +import { logger } from "react-native-logs"; type CampaignScreenProps = ViewerTabProps<'Campaign'> @@ -173,7 +174,10 @@ const CampaignScreen: FC = ({ navigation }) => { checkIfPaywallOpen(); }, (event: NamiPaywallEvent) => { - console.log('event', event); + + var log = logger.createLogger(); + // console.log(`NamiPaywallEvent ${event}"`) + log.info(`NamiPaywallEvent ${event}"`) setAction(event.action); }, ); diff --git a/examples/Basic/package.json b/examples/Basic/package.json index d15ac2b7..2ca06819 100644 --- a/examples/Basic/package.json +++ b/examples/Basic/package.json @@ -30,7 +30,8 @@ "react-native-nami-sdk": "file:../../", "react-native-reanimated": "^3.8.1", "react-native-safe-area-context": "^4.10.7", - "react-native-screens": "3.30.1" + "react-native-screens": "3.30.1", + "react-native-logs": "^5.1.0" }, "devDependencies": { "@babel/core": "^7.20.0", From 17cfad6f817cbf83f8f338a3eb698d669cffdde4 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 22:31:53 -0600 Subject: [PATCH 19/25] lint --- examples/Basic/containers/CampaignScreen.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index a9a5fa9c..77713315 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -27,7 +27,7 @@ import theme from '../theme'; import { SafeAreaView } from 'react-native-safe-area-context'; import { handleDeepLink } from '../services/deeplinking'; import customLaunchObject from '../nami_launch_context_custom_object.json'; -import { logger } from "react-native-logs"; +import { logger } from 'react-native-logs'; type CampaignScreenProps = ViewerTabProps<'Campaign'> @@ -175,7 +175,7 @@ const CampaignScreen: FC = ({ navigation }) => { }, (event: NamiPaywallEvent) => { - var log = logger.createLogger(); + const log = logger.createLogger(); // console.log(`NamiPaywallEvent ${event}"`) log.info(`NamiPaywallEvent ${event}"`) setAction(event.action); From 8c0f042c460d89d4e690050d8ee89ed1c8cc85da Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 22:59:05 -0600 Subject: [PATCH 20/25] logging toString --- examples/Basic/containers/CampaignScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index 77713315..4d0aeb3f 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -177,7 +177,7 @@ const CampaignScreen: FC = ({ navigation }) => { const log = logger.createLogger(); // console.log(`NamiPaywallEvent ${event}"`) - log.info(`NamiPaywallEvent ${event}"`) + log.info(`NamiPaywallEvent ${event.toString}"`) setAction(event.action); }, ); From d90bd7834a5af2f9f87b3afce79470caeef583cd Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 23:20:48 -0600 Subject: [PATCH 21/25] detox config --- examples/Basic/.detoxrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/Basic/.detoxrc.js b/examples/Basic/.detoxrc.js index 53b53a40..bead78e8 100644 --- a/examples/Basic/.detoxrc.js +++ b/examples/Basic/.detoxrc.js @@ -88,6 +88,7 @@ module.exports = { 'android.emu.release': { device: 'emulator', app: 'production.android.release', + forceAdbInstall: true, }, 'android.emu.debug.local': { device: 'emulatorLocal', From f3ba8cabb16bfebc701c23fb748c7b1aa40f6816 Mon Sep 17 00:00:00 2001 From: dannami Date: Tue, 23 Jul 2024 23:23:17 -0600 Subject: [PATCH 22/25] toString --- examples/Basic/containers/CampaignScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index 4d0aeb3f..94b418d8 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -177,7 +177,7 @@ const CampaignScreen: FC = ({ navigation }) => { const log = logger.createLogger(); // console.log(`NamiPaywallEvent ${event}"`) - log.info(`NamiPaywallEvent ${event.toString}"`) + log.info(`NamiPaywallEvent ${event.toString()}"`) setAction(event.action); }, ); From 2714a32ea7bffbe3c3787292ff716e993ef8cdab Mon Sep 17 00:00:00 2001 From: dannami Date: Wed, 24 Jul 2024 07:50:12 -0600 Subject: [PATCH 23/25] improve logging --- examples/Basic/containers/CampaignScreen.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index 94b418d8..6ee466f3 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -177,7 +177,18 @@ const CampaignScreen: FC = ({ navigation }) => { const log = logger.createLogger(); // console.log(`NamiPaywallEvent ${event}"`) - log.info(`NamiPaywallEvent ${event.toString()}"`) + log.info(`NamiPaywallEvent action - ${event.action.toString()}"`); + log.info(`NamiPaywallEvent timeSpentOnPaywall - ${event.timeSpentOnPaywall?.toString()}"`); + log.info(`NamiPaywallEvent component change id - ${event.componentChange?.id?.toString()}"`); + log.info(`NamiPaywallEvent component change name - ${event.componentChange?.name?.toString()}"`); + log.info(`NamiPaywallEvent video metadata id - ${event.videoMetadata?.id?.toString()}"`); + log.info(`NamiPaywallEvent video metadata url - ${event.videoMetadata?.url?.toString()}"`); + log.info(`NamiPaywallEvent video metadata name - ${event.videoMetadata?.name?.toString()}"`); + log.info(`NamiPaywallEvent video metadata contentDuration - ${event.videoMetadata?.contentDuration?.toString()}"`); + log.info(`NamiPaywallEvent video metadata contentTimecode - ${event.videoMetadata?.contentTimecode?.toString()}"`); + log.info(`NamiPaywallEvent video metadata autoplayVideo - ${event.videoMetadata?.autoplayVideo?.toString()}"`); + log.info(`NamiPaywallEvent video metadata muteByDefault - ${event.videoMetadata?.muteByDefault?.toString()}"`); + log.info(`NamiPaywallEvent video metadata loopVideo - ${event.videoMetadata?.loopVideo?.toString()}"`); setAction(event.action); }, ); From 15b1ad66757a95ffd85dfe42140cee8215c6c3e5 Mon Sep 17 00:00:00 2001 From: dannami Date: Wed, 24 Jul 2024 07:53:40 -0600 Subject: [PATCH 24/25] bump android version to 3.2.1 --- android/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 9abcc007..ae3b6aa9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -85,8 +85,8 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - playImplementation "com.namiml:sdk-android:3.2.1-beta.02" - amazonImplementation "com.namiml:sdk-amazon:3.2.1-beta.02" + playImplementation "com.namiml:sdk-android:3.2.1" + amazonImplementation "com.namiml:sdk-amazon:3.2.1" implementation "com.facebook.react:react-native:+" // From node_modules coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" From d35cf9daf188791ebb2f592a280c45c1224c35f3 Mon Sep 17 00:00:00 2001 From: dannami Date: Wed, 24 Jul 2024 10:02:29 -0600 Subject: [PATCH 25/25] fix video metadata reference --- .../java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt | 1 + ios/NamiCampaignManagerBridge.swift | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt index 749fc8b0..b18a7d2e 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt @@ -183,6 +183,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : val videoMetadataMap = Arguments.createMap().apply { putString("id", paywallEvent.videoMetadata?.id ?: "") putString("name", paywallEvent.videoMetadata?.name ?: "") + putString("url", paywallEvent.videoMetadata?.url ?: "") putBoolean("autoplayVideo", paywallEvent.videoMetadata?.autoplayVideo ?: false) putBoolean("muteByDefault", paywallEvent.videoMetadata?.muteByDefault ?: false) putBoolean("loopVideo", paywallEvent.videoMetadata?.loopVideo ?: false) diff --git a/ios/NamiCampaignManagerBridge.swift b/ios/NamiCampaignManagerBridge.swift index b9a4f698..75806e7e 100644 --- a/ios/NamiCampaignManagerBridge.swift +++ b/ios/NamiCampaignManagerBridge.swift @@ -118,7 +118,7 @@ class RNNamiCampaignManager: RCTEventEmitter { if let eventVideoMetadata = paywallEvent.videoMetadata { videoMetadata["id"] = eventVideoMetadata.id videoMetadata["name"] = eventVideoMetadata.name - videoMetadata["url"] = eventVideoMetadata.name + videoMetadata["url"] = eventVideoMetadata.url videoMetadata["loopVideo"] = eventVideoMetadata.loopVideo videoMetadata["muteByDefault"] = eventVideoMetadata.muteByDefault videoMetadata["autoplayVideo"] = eventVideoMetadata.autoplayVideo