From c9a4beb94da73ddac3099777bbb1ee4b8f56df20 Mon Sep 17 00:00:00 2001 From: sozinov Date: Mon, 13 Apr 2026 15:27:29 +0300 Subject: [PATCH 1/9] MOBILE-103: bump RN to 0.76.0 in example --- example/exampleApp/android/app/build.gradle | 18 ++---- example/exampleApp/android/build.gradle | 27 ++++---- example/exampleApp/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/exampleApp/android/settings.gradle | 19 ++++-- example/exampleApp/ios/Podfile | 40 ++++++------ .../ios/exampleApp.xcodeproj/project.pbxproj | 12 ++-- .../ios/exampleApp/PrivacyInfo.xcprivacy | 54 ++++++++++------ example/exampleApp/package.json | 31 +++++---- example/exampleApp/src/App.tsx | 31 +++++---- example/exampleApp/src/screens/HomeScreen.tsx | 63 +++++++++---------- .../src/screens/NotificationCenterScreen.tsx | 4 +- .../src/screens/PushNotificationScreen.tsx | 9 ++- 13 files changed, 170 insertions(+), 142 deletions(-) diff --git a/example/exampleApp/android/app/build.gradle b/example/exampleApp/android/app/build.gradle index c9adc89..f5a2b19 100644 --- a/example/exampleApp/android/app/build.gradle +++ b/example/exampleApp/android/app/build.gradle @@ -1,14 +1,14 @@ apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" -apply plugin: 'com.google.gms.google-services' -apply plugin: 'kotlin-android' -apply plugin: 'com.huawei.agconnect' - +apply plugin: "com.google.gms.google-services" +apply plugin: "kotlin-android" +apply plugin: "com.huawei.agconnect" react { - + autolinkLibrariesWithApp() } + def enableProguardInReleaseBuilds = false def jscFlavor = 'org.webkit:android-jsc:+' @@ -47,9 +47,6 @@ android { dependencies { implementation("com.facebook.react:react-android") - implementation "com.facebook.react:react-native:0.74.0" - - // Integration of Mindbox SDK and necessary Firebase and Huawei services for mobile push notifications functionality implementation platform('com.google.firebase:firebase-bom:29.3.1') implementation 'com.google.firebase:firebase-analytics-ktx' implementation 'com.google.firebase:firebase-messaging-ktx' @@ -58,8 +55,6 @@ dependencies { implementation 'com.huawei.hms:push:6.7.0.300' implementation 'cloud.mindbox:mindbox-rustore' implementation 'ru.rustore.sdk:pushclient:6.5.1' - - //gson implementation 'com.google.code.gson:gson:2.8.8' if (hermesEnabled.toBoolean()) { @@ -68,6 +63,3 @@ dependencies { implementation jscFlavor } } - -apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) - diff --git a/example/exampleApp/android/build.gradle b/example/exampleApp/android/build.gradle index d2f118c..2bcf733 100644 --- a/example/exampleApp/android/build.gradle +++ b/example/exampleApp/android/build.gradle @@ -1,46 +1,43 @@ buildscript { ext { - buildToolsVersion = "34.0.0" - minSdkVersion = 23 + buildToolsVersion = "35.0.0" + minSdkVersion = 24 compileSdkVersion = 35 targetSdkVersion = 35 ndkVersion = "26.1.10909125" - kotlinVersion = "1.8.0" - cmakeVersion = "3.22.1" + kotlinVersion = "1.9.24" } repositories { google() mavenCentral() maven { url 'https://developer.huawei.com/repo/' } - maven {url 'https://artifactory-external.vkpartner.ru/artifactory/maven'} + maven { url 'https://artifactory-external.vkpartner.ru/artifactory/maven' } } dependencies { classpath("com.android.tools.build:gradle:8.6.0") - classpath("com.facebook.react:react-native-gradle-plugin:7.5") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") - classpath 'com.google.gms:google-services:4.3.14' - classpath "com.huawei.agconnect:agcp:1.8.0.300" + classpath("com.facebook.react:react-native-gradle-plugin") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") + classpath("com.google.gms:google-services:4.3.14") + classpath("com.huawei.agconnect:agcp:1.8.0.300") } } + allprojects { repositories { mavenCentral() 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() - maven { url 'https://www.jitpack.io' } + maven { url "https://www.jitpack.io" } maven { url "https://plugins.gradle.org/m2/" } - maven { url 'https://developer.huawei.com/repo/' } - maven {url 'https://artifactory-external.vkpartner.ru/artifactory/maven'} + maven { url "https://developer.huawei.com/repo/" } + maven { url "https://artifactory-external.vkpartner.ru/artifactory/maven" } } - } apply plugin: "com.facebook.react.rootproject" diff --git a/example/exampleApp/android/gradle.properties b/example/exampleApp/android/gradle.properties index 1351076..9cc1566 100644 --- a/example/exampleApp/android/gradle.properties +++ b/example/exampleApp/android/gradle.properties @@ -26,7 +26,7 @@ android.enableJetifier=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 +# ./gradlew -PreactNativeArchitectures=x86_64 reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 # Use this property to enable support to the new architecture. diff --git a/example/exampleApp/android/gradle/wrapper/gradle-wrapper.properties b/example/exampleApp/android/gradle/wrapper/gradle-wrapper.properties index e7646de..79eb9d0 100644 --- a/example/exampleApp/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/exampleApp/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/example/exampleApp/android/settings.gradle b/example/exampleApp/android/settings.gradle index e9ce508..b27a69e 100644 --- a/example/exampleApp/android/settings.gradle +++ b/example/exampleApp/android/settings.gradle @@ -1,4 +1,15 @@ -rootProject.name = 'exampleApp' -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') +pluginManagement { + includeBuild("../node_modules/@react-native/gradle-plugin") +} + +plugins { + id("com.facebook.react.settings") +} + +extensions.configure(com.facebook.react.ReactSettingsExtension) { ex -> + ex.autolinkLibrariesFromCommand() +} + +rootProject.name = "exampleApp" +include(":app") +includeBuild("../node_modules/@react-native/gradle-plugin") diff --git a/example/exampleApp/ios/Podfile b/example/exampleApp/ios/Podfile index b70ff6c..80262f4 100644 --- a/example/exampleApp/ios/Podfile +++ b/example/exampleApp/ios/Podfile @@ -1,14 +1,14 @@ -def node_require(script) - # Resolve script with node to allow for hoisting - require Pod::Executable.execute_command('node', ['-p', - "require.resolve( - '#{script}', - {paths: [process.argv[1]]}, - )", __dir__]).strip -end - -node_require('react-native/scripts/react_native_pods.rb') -node_require('react-native-permissions/scripts/setup.rb') +require Pod::Executable.execute_command('node', ['-p', + 'require.resolve( + "react-native/scripts/react_native_pods.rb", + {paths: [process.argv[1]]}, + )', __dir__]).strip + +require Pod::Executable.execute_command('node', ['-p', + 'require.resolve( + "react-native-permissions/scripts/setup.rb", + {paths: [process.argv[1]]}, + )', __dir__]).strip platform :ios, min_ios_version_supported prepare_react_native_project! @@ -26,26 +26,25 @@ target 'exampleApp' do use_react_native!( :path => config[:reactNativePath], - # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) pod 'Mindbox' -target 'MindboxNotificationServiceExtension' do - pod 'MindboxNotifications' + target 'MindboxNotificationServiceExtension' do + pod 'MindboxNotifications' end -target 'MindboxNotificationContentExtension' do - pod 'MindboxNotifications' + target 'MindboxNotificationContentExtension' do + pod 'MindboxNotifications' end post_install do |installer| installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No' - end - end + target.build_configurations.each do |buildConfig| + buildConfig.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No' + end + end react_native_post_install( installer, config[:reactNativePath], @@ -53,4 +52,3 @@ target 'MindboxNotificationContentExtension' do ) end end - diff --git a/example/exampleApp/ios/exampleApp.xcodeproj/project.pbxproj b/example/exampleApp/ios/exampleApp.xcodeproj/project.pbxproj index a267e63..83002a2 100644 --- a/example/exampleApp/ios/exampleApp.xcodeproj/project.pbxproj +++ b/example/exampleApp/ios/exampleApp.xcodeproj/project.pbxproj @@ -585,6 +585,7 @@ DEVELOPMENT_TEAM = 622436AMYX; ENABLE_BITCODE = NO; INFOPLIST_FILE = exampleApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -619,6 +620,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 622436AMYX; INFOPLIST_FILE = exampleApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -663,7 +665,7 @@ INFOPLIST_FILE = MindboxNotificationServiceExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = MindboxNotificationServiceExtension; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -710,7 +712,7 @@ INFOPLIST_FILE = MindboxNotificationServiceExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = MindboxNotificationServiceExtension; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -754,7 +756,7 @@ INFOPLIST_FILE = MindboxNotificationContentExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = MindboxNotificationContentExtension; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -800,7 +802,7 @@ INFOPLIST_FILE = MindboxNotificationContentExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = MindboxNotificationContentExtension; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -898,7 +900,7 @@ ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG"; USE_HERMES = true; }; name = Debug; diff --git a/example/exampleApp/ios/exampleApp/PrivacyInfo.xcprivacy b/example/exampleApp/ios/exampleApp/PrivacyInfo.xcprivacy index 01ce452..2d04442 100644 --- a/example/exampleApp/ios/exampleApp/PrivacyInfo.xcprivacy +++ b/example/exampleApp/ios/exampleApp/PrivacyInfo.xcprivacy @@ -2,10 +2,33 @@ - NSPrivacyTracking - - NSPrivacyTrackingDomains - + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA92.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + NSPrivacyCollectedDataTypes @@ -13,36 +36,29 @@ NSPrivacyCollectedDataTypeOtherDiagnosticData NSPrivacyCollectedDataTypeLinked - NSPrivacyCollectedDataTypeTracking - NSPrivacyCollectedDataTypePurposes NSPrivacyCollectedDataTypePurposeAppFunctionality + NSPrivacyCollectedDataTypeTracking + NSPrivacyCollectedDataType NSPrivacyCollectedDataTypeDeviceID NSPrivacyCollectedDataTypeLinked - NSPrivacyCollectedDataTypeTracking - NSPrivacyCollectedDataTypePurposes NSPrivacyCollectedDataTypePurposeProductPersonalization + NSPrivacyCollectedDataTypeTracking + - NSPrivacyAccessedAPITypes - - - NSPrivacyAccessedAPIType - NSPrivacyAccessedAPICategoryUserDefaults - NSPrivacyAccessedAPITypeReasons - - CA92.1 - - - + NSPrivacyTracking + + NSPrivacyTrackingDomains + diff --git a/example/exampleApp/package.json b/example/exampleApp/package.json index a755306..f8c11e4 100644 --- a/example/exampleApp/package.json +++ b/example/exampleApp/package.json @@ -12,26 +12,23 @@ "test": "jest" }, "dependencies": { - "@react-navigation/native": "^6.1.6", - "@react-navigation/native-stack": "^6.9.17", - "@react-navigation/stack": "^6.3.20", - "mindbox-sdk": "^2.13.1", - "react": "18.2.0", - "react-native": "0.74.0", - "react-native-gesture-handler": "2.21.2", + "mindbox-sdk": "^2.15.0", + "react": "18.3.1", + "react-native": "0.76.0", "react-native-permissions": "^5.4.0", - "react-native-safe-area-context": "^4.9.0", - "react-native-screens": "^3.29.0", "react-native-snackbar": "^2.8.0" }, "devDependencies": { - "@babel/core": "^7.20.0", - "@babel/preset-env": "^7.20.0", - "@babel/runtime": "^7.20.0", - "@react-native/babel-preset": "0.74.0", - "@react-native/eslint-config": "0.74.0", - "@react-native/metro-config": "0.74.0", - "@react-native/typescript-config": "0.74.0", + "@babel/core": "^7.25.2", + "@babel/preset-env": "^7.25.3", + "@babel/runtime": "^7.25.0", + "@react-native-community/cli": "15.0.0", + "@react-native-community/cli-platform-android": "15.0.0", + "@react-native-community/cli-platform-ios": "15.0.0", + "@react-native/babel-preset": "0.76.0", + "@react-native/eslint-config": "0.76.0", + "@react-native/metro-config": "0.76.0", + "@react-native/typescript-config": "0.76.0", "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", @@ -39,7 +36,7 @@ "husky": "^9.0.10", "jest": "^29.6.3", "prettier": "2.8.8", - "react-test-renderer": "18.2.0", + "react-test-renderer": "18.3.1", "typescript": "5.0.4" }, "engines": { diff --git a/example/exampleApp/src/App.tsx b/example/exampleApp/src/App.tsx index 5330f4d..3f4caf0 100644 --- a/example/exampleApp/src/App.tsx +++ b/example/exampleApp/src/App.tsx @@ -1,21 +1,28 @@ -import React from 'react' -import { NavigationContainer } from '@react-navigation/native' -import { createNativeStackNavigator } from '@react-navigation/native-stack' +import React, { useMemo, useState } from 'react' +import { AppNavigationContext, RouteName } from './navigation/AppNavigationContext' import HomeScreen from './screens/HomeScreen' import PushNotificationScreen from './screens/PushNotificationScreen' import NotificationCenterScreen from './screens/NotificationCenterScreen' -const Stack = createNativeStackNavigator() - function App() { + const [route, setRoute] = useState('Home') + const navigation = useMemo( + () => ({ + navigate: (name: RouteName) => { + setRoute(name) + }, + goBack: () => { + setRoute('Home') + }, + }), + [] + ) return ( - - - - - - - + + {route === 'Home' ? : null} + {route === 'PushNotification' ? : null} + {route === 'NotificationCenter' ? : null} + ) } diff --git a/example/exampleApp/src/screens/HomeScreen.tsx b/example/exampleApp/src/screens/HomeScreen.tsx index 17c52e4..ebb9573 100644 --- a/example/exampleApp/src/screens/HomeScreen.tsx +++ b/example/exampleApp/src/screens/HomeScreen.tsx @@ -3,8 +3,7 @@ import { SafeAreaView, StyleSheet, Text, View, Platform, Button } from 'react-na import MindboxSdk, { LogLevel, CopyPayloadInAppCallback, EmptyInAppCallback, InAppCallback, UrlInAppCallback } from 'mindbox-sdk' import { sendSync, sendAsync, asyncOperationNCOpen } from '../utils/MindboxOperations' import { requestNotificationPermission } from '../utils/RequestPermission' -import PushNotificationScreen from './screens/PushNotificationScreen' -import { useNavigation } from '@react-navigation/native' +import { useAppNavigation } from '../navigation/AppNavigationContext' import { chooseInappCallback, RegisterInappCallback } from '../utils/InAppCallbacks' const configuration = { @@ -16,7 +15,7 @@ const configuration = { } const HomeScreen = () => { - const navigation = useNavigation() + const navigation = useAppNavigation() const [deviceUUID, setDeviceUUID] = useState('Empty') const [token, setToken] = useState('Empty') const [pushData, setPushData] = useState({ @@ -25,6 +24,35 @@ const HomeScreen = () => { }) const [sdkVersion, setSdkVersion] = useState('Empty') + const appInitializationCallback = useCallback(async () => { + try { + // https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#mindboxinitialize + await MindboxSdk.initialize(configuration) + } catch (error) { + console.log(error) + } + }, []) + + const navigateToPushNotificationIfRequired = useCallback( + (pushUrl: string | null) => { + if (pushUrl != null && pushUrl.includes('gotoanotherscreen')) { + navigation.navigate('PushNotification') + } + }, + [navigation] + ) + + const getPushData = useCallback( + (pushUrl: string | null, pushPayload: string | null) => { + setTimeout(() => { + // https://developers.mindbox.ru/docs/flutter-push-navigation-react-native + navigateToPushNotificationIfRequired(pushUrl) + setPushData({ pushUrl, pushPayload }) + }, 600) + }, + [navigateToPushNotificationIfRequired] + ) + useEffect(() => { // https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#setloglevel-since-280 MindboxSdk.setLogLevel(LogLevel.DEBUG) @@ -51,26 +79,6 @@ const HomeScreen = () => { chooseInappCallback(RegisterInappCallback.DEFAULT) }, [appInitializationCallback]) - const appInitializationCallback = useCallback(async () => { - try { - // https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#mindboxinitialize - await MindboxSdk.initialize(configuration) - } catch (error) { - console.log(error) - } - }, []) - - const getPushData = useCallback( - (pushUrl: String | null, pushPayload: String | null) => { - setTimeout(() => { - // https://developers.mindbox.ru/docs/flutter-push-navigation-react-native - navigateToPushNotificationIfRequired(pushUrl) - setPushData({ pushUrl, pushPayload }) - }, 600) - }, - [navigateToPushNotificationIfRequired] - ) - useEffect(() => { // https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#onpushclickreceived MindboxSdk.onPushClickReceived(getPushData) @@ -88,15 +96,6 @@ const HomeScreen = () => { asyncOperationNCOpen() navigation.navigate('NotificationCenter') } - - const navigateToPushNotificationIfRequired = useCallback( - (pushUrl) => { - if (pushUrl && pushUrl.includes('gotoanotherscreen')) { - navigation.navigate('PushNotification') - } - }, - [navigation] - ) return ( diff --git a/example/exampleApp/src/screens/NotificationCenterScreen.tsx b/example/exampleApp/src/screens/NotificationCenterScreen.tsx index 4abc0ab..f65a4bd 100644 --- a/example/exampleApp/src/screens/NotificationCenterScreen.tsx +++ b/example/exampleApp/src/screens/NotificationCenterScreen.tsx @@ -6,11 +6,13 @@ import { asyncOperationNCPushOpen } from '../utils/MindboxOperations' import initialNotifications from '../utils/NotificationStub' import styles from '../components/NotificationScreenStyles' import { Notification } from '../utils/Notification' +import { useAppNavigation } from '../navigation/AppNavigationContext' const { NotificationModule } = NativeModules const notificationEmitter = new NativeEventEmitter(NotificationModule) -const NotificationCenterScreen = ({ navigation }: { navigation: any }) => { +const NotificationCenterScreen = () => { + const navigation = useAppNavigation() const [notifications, setNotifications] = useState([]) useEffect(() => { diff --git a/example/exampleApp/src/screens/PushNotificationScreen.tsx b/example/exampleApp/src/screens/PushNotificationScreen.tsx index 13297a0..9b94a66 100644 --- a/example/exampleApp/src/screens/PushNotificationScreen.tsx +++ b/example/exampleApp/src/screens/PushNotificationScreen.tsx @@ -1,10 +1,14 @@ import React from 'react' -import { View, Text, StyleSheet } from 'react-native' +import { View, Text, StyleSheet, Button } from 'react-native' +import { useAppNavigation } from '../navigation/AppNavigationContext' const PushNotificationScreen = () => { + const navigation = useAppNavigation() return ( Opened after click on push + +