From 1072ce01a31066c5b3711c96741a44f592f3f6eb Mon Sep 17 00:00:00 2001 From: Harun Karahan <32582360+karahanharunn@users.noreply.github.com> Date: Thu, 11 Dec 2025 13:42:54 +0100 Subject: [PATCH] Revert "migration from react-native-push-notification to notifee" --- CHANGELOG.md | 4 -- android/build.gradle | 3 -- capabilities-setup-config.json | 18 ++++++++ ios/AppDelegate.h | 3 +- ios/AppDelegate.m | 26 ++++++++++++ ios/Dev/AppDelegate.m | 26 ++++++++++++ ios/MendixAppDelegate.h | 16 ++++++++ ios/Podfile.lock | 17 ++++---- ios/mendix_utils.rb | 36 ++++++++++++++++ package-lock.json | 41 ++++++++++++------- package.json | 5 ++- ...react-native-push-notification+8.1.1.patch | 17 ++++++++ 12 files changed, 178 insertions(+), 34 deletions(-) create mode 100644 patches/react-native-push-notification+8.1.1.patch diff --git a/CHANGELOG.md b/CHANGELOG.md index dd4632035..ab4ab059a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,10 +16,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - We have improved the styling where edge-to-edge mode is enabled. -### Changed - -- We have migrated from `react-native-push-notification` to `@notifee/react-native` for better new architecture compatibility and enhanced push notification features. - ## Fixes - We have upgraded `@mendix/native` to version 9.0.1 diff --git a/android/build.gradle b/android/build.gradle index 5df663d05..504dc2292 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -80,9 +80,6 @@ allprojects { url "https://maven.scijava.org/content/repositories/jcenter/" } maven { url "https://packages.rnd.mendix.com/jcenter" } - maven { - url "$rootDir/../node_modules/@notifee/react-native/android/libs" - } } // Build all modules with Android 16KB pages enabled diff --git a/capabilities-setup-config.json b/capabilities-setup-config.json index 74943f98b..15da292c9 100644 --- a/capabilities-setup-config.json +++ b/capabilities-setup-config.json @@ -36,6 +36,24 @@ "externalDependencies": [ "me.leolin:ShortcutBadger:1.1.22@aar" ] + }, + "ios": { + "AppDelegate": { + "imports": [ + "#import " + ], + "didFinishLaunchingWithOptions": [ + "UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];", + "center.delegate = MendixAppDelegate.delegate;" + ], + "willPresentNotification": [ + "completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);" + ], + "didReceiveNotificationResponse": [ + "[RNCPushNotificationIOS didReceiveNotificationResponse:response];", + "completionHandler();" + ] + } } }, "firebaseAndroid": { diff --git a/ios/AppDelegate.h b/ios/AppDelegate.h index 23abd9f1a..4abc56d3d 100644 --- a/ios/AppDelegate.h +++ b/ios/AppDelegate.h @@ -1,7 +1,8 @@ #import #import +#import -@interface AppDelegate : UIResponder +@interface AppDelegate : UIResponder @property (nonatomic, strong) UIWindow *window; @property BOOL shouldOpenInLastApp; diff --git a/ios/AppDelegate.m b/ios/AppDelegate.m index c1afb4257..54327796a 100644 --- a/ios/AppDelegate.m +++ b/ios/AppDelegate.m @@ -11,6 +11,7 @@ @implementation AppDelegate - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self clearKeychain]; + MendixAppDelegate.delegate = self; [MendixAppDelegate application:application didFinishLaunchingWithOptions:launchOptions]; [self setupUI]; @@ -38,6 +39,19 @@ - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions: return YES; } +- (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { + [MendixAppDelegate application:application didReceiveLocalNotification:notification]; +} + +- (void) application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo +fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{ + [MendixAppDelegate application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; +} + +- (void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { + [MendixAppDelegate application:application didRegisterUserNotificationSettings:notificationSettings]; +} + - (BOOL) application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { return [MendixAppDelegate application:app openURL:url options:options]; } @@ -60,6 +74,18 @@ - (void) setupUI { } } +- (void) userNotificationCenter:(UNUserNotificationCenter *)center + willPresentNotification:(UNNotification *)notification + withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { + [MendixAppDelegate userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler]; +} + +- (void) userNotificationCenter:(UNUserNotificationCenter *)center + didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void (^)(void))completionHandler { + [MendixAppDelegate userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; +} + - (void) clearKeychain { if ([NSUserDefaults.standardUserDefaults boolForKey:@"HAS_RUN_BEFORE"] == NO) { [NSUserDefaults.standardUserDefaults setBool:YES forKey:@"HAS_RUN_BEFORE"]; diff --git a/ios/Dev/AppDelegate.m b/ios/Dev/AppDelegate.m index b48bbc87b..c86cd2475 100644 --- a/ios/Dev/AppDelegate.m +++ b/ios/Dev/AppDelegate.m @@ -11,6 +11,7 @@ @implementation AppDelegate - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self clearKeychain]; + MendixAppDelegate.delegate = self; [MendixAppDelegate application:application didFinishLaunchingWithOptions:launchOptions]; [self setupUI]; @@ -24,6 +25,19 @@ - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions: return YES; } +- (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { + [MendixAppDelegate application:application didReceiveLocalNotification:notification]; +} + +- (void) application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo +fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{ + [MendixAppDelegate application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; +} + +- (void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { + [MendixAppDelegate application:application didRegisterUserNotificationSettings:notificationSettings]; +} + - (BOOL) application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { BOOL isHandled = [MendixAppDelegate application:application openURL:url options:options]; @@ -68,6 +82,18 @@ - (void) setupUI { } } +- (void) userNotificationCenter:(UNUserNotificationCenter *)center + willPresentNotification:(UNNotification *)notification + withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { + [MendixAppDelegate userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler]; +} + +- (void) userNotificationCenter:(UNUserNotificationCenter *)center + didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void (^)(void))completionHandler { + [MendixAppDelegate userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler]; +} + - (void) clearKeychain { if ([NSUserDefaults.standardUserDefaults boolForKey:@"HAS_RUN_BEFORE"] == NO) { [NSUserDefaults.standardUserDefaults setBool:YES forKey:@"HAS_RUN_BEFORE"]; diff --git a/ios/MendixAppDelegate.h b/ios/MendixAppDelegate.h index cae4b45dd..d3e6e5016 100644 --- a/ios/MendixAppDelegate.h +++ b/ios/MendixAppDelegate.h @@ -1,12 +1,28 @@ #import +#import @interface MendixAppDelegate : NSObject + (void) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; ++ (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification; + ++ (void) application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo +fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler; + ++ (void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings; + + (BOOL) application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options; + (void) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; ++ (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler; + ++ (void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler; + ++ (UIResponder *_Nullable) delegate; + ++ (void) setDelegate:(UIResponder *_Nonnull)value; + + (NSURL *) getJSBundleFile; @end diff --git a/ios/Podfile.lock b/ios/Podfile.lock index ca3cb92dd..a37f2128e 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1636,6 +1636,8 @@ PODS: - React-Core - RNCPicker (2.11.0): - React-Core + - RNCPushNotificationIOS (1.10.1): + - React-Core - RNDateTimePicker (8.2.0): - React-Core - RNDeviceInfo (13.0.0): @@ -1667,11 +1669,6 @@ PODS: - Yoga - RNLocalize (3.2.1): - React-Core - - RNNotifee (9.1.8): - - React-Core - - RNNotifee/NotifeeCore (= 9.1.8) - - RNNotifee/NotifeeCore (9.1.8): - - React-Core - RNPermissions (4.1.5): - React-Core - RNReanimated (3.16.1): @@ -1898,12 +1895,12 @@ DEPENDENCIES: - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)" - "RNCMaskedView (from `../node_modules/@react-native-masked-view/masked-view`)" - "RNCPicker (from `../node_modules/@react-native-picker/picker`)" + - "RNCPushNotificationIOS (from `../node_modules/@react-native-community/push-notification-ios`)" - "RNDateTimePicker (from `../node_modules/@react-native-community/datetimepicker`)" - RNDeviceInfo (from `../node_modules/react-native-device-info`) - RNFastImage (from `../node_modules/react-native-fast-image`) - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) - RNLocalize (from `../node_modules/react-native-localize`) - - "RNNotifee (from `../node_modules/@notifee/react-native`)" - RNPermissions (from `../node_modules/react-native-permissions`) - RNReanimated (from `../node_modules/react-native-reanimated`) - RNScreens (from `../node_modules/react-native-screens`) @@ -2077,6 +2074,8 @@ EXTERNAL SOURCES: :path: "../node_modules/@react-native-masked-view/masked-view" RNCPicker: :path: "../node_modules/@react-native-picker/picker" + RNCPushNotificationIOS: + :path: "../node_modules/@react-native-community/push-notification-ios" RNDateTimePicker: :path: "../node_modules/@react-native-community/datetimepicker" RNDeviceInfo: @@ -2087,8 +2086,6 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-gesture-handler" RNLocalize: :path: "../node_modules/react-native-localize" - RNNotifee: - :path: "../node_modules/@notifee/react-native" RNPermissions: :path: "../node_modules/react-native-permissions" RNReanimated: @@ -2184,12 +2181,12 @@ SPEC CHECKSUMS: RNCAsyncStorage: 40367e8d25522dca9c3513c7b9815a184669bd97 RNCMaskedView: de80352547bd4f0d607bf6bab363d826822bd126 RNCPicker: 124b4fb5859ba1a3fd53a91e16d1e7a0fc016e59 + RNCPushNotificationIOS: 778dc253960de7b6544abe6cee86fea1e2c590ab RNDateTimePicker: 818460dc31b0dc5ec58289003e27dd8d022fb79c RNDeviceInfo: ae4e1a9b955b2a65314588cc7251795631925668 RNFastImage: 462a183c4b0b6b26fdfd639e1ed6ba37536c3b87 RNGestureHandler: 9bf6e8f72d2e72c8f7eb45986fe71a5005fb072d RNLocalize: e7378161f0b6a6365407eb2377aab46cc38047d8 - RNNotifee: 5e3b271e8ea7456a36eec994085543c9adca9168 RNPermissions: 6a02e3cb2c65fbcdceb5111131e7725cda40efd2 RNReanimated: 20f0d150af988258289b2d6cda655bd14945a769 RNScreens: 86e5c168cdd055a8feead28eb756ca7103918b6a @@ -2202,6 +2199,6 @@ SPEC CHECKSUMS: SSZipArchive: 8a6ee5677c8e304bebc109e39cf0da91ccef22ea Yoga: 92f3bb322c40a86b7233b815854730442e01b8c4 -PODFILE CHECKSUM: d2c49e3c6af7627753459536d224c58f75141533 +PODFILE CHECKSUM: 0721d8defdcee9bbb168ccd39c73b4972842a2af COCOAPODS: 1.16.2 diff --git a/ios/mendix_utils.rb b/ios/mendix_utils.rb index b995cd595..f9764bafd 100644 --- a/ios/mendix_utils.rb +++ b/ios/mendix_utils.rb @@ -37,7 +37,12 @@ def generate_mendix_delegate imports = [] hooks = { didFinishLaunchingWithOptions: [], + didReceiveLocalNotification: [], + didReceiveRemoteNotification: [], + didRegisterUserNotificationSettings: [], openURL: [], + willPresentNotification: [], + didReceiveNotificationResponse: [], getJSBundleFile: [], } @@ -89,10 +94,25 @@ def mendix_app_delegate_template @implementation MendixAppDelegate +static UIResponder *_Nullable delegate; + + (void) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { {{ didFinishLaunchingWithOptions }} } ++ (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { +{{ didReceiveLocalNotification }} +} + ++ (void) application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo +fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{ +{{ didReceiveRemoteNotification }} +} + ++ (void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { +{{ didRegisterUserNotificationSettings }} +} + + (BOOL) application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { {{ boolean_openURLWithOptions }} } @@ -101,6 +121,22 @@ def mendix_app_delegate_template {{ openURL }} } ++ (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { +{{ willPresentNotification }} +} + ++ (void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { +{{ didReceiveNotificationResponse }} +} + ++ (UIResponder *_Nullable) delegate { + return delegate; +} + ++ (void) setDelegate:(UIResponder *_Nonnull)value { + delegate = value; +} + + (NSURL *) getJSBundleFile { {{ getJSBundleFile }} return [ReactNative.instance getJSBundleFile]; diff --git a/package-lock.json b/package-lock.json index abc55ee50..9545240c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,7 @@ "hasInstallScript": true, "dependencies": { "@gorhom/bottom-sheet": "^5.1.1", - "@mendix/native": "9.2.1", - "@notifee/react-native": "9.1.8", + "@mendix/native": "9.2.0", "@op-engineering/op-sqlite": "9.2.7", "@react-native-async-storage/async-storage": "2.0.0", "@react-native-camera-roll/camera-roll": "7.4.0", @@ -19,6 +18,7 @@ "@react-native-community/cli-platform-android": "16.0.2", "@react-native-community/cli-platform-ios": "16.0.2", "@react-native-community/datetimepicker": "8.2.0", + "@react-native-community/push-notification-ios": "1.10.1", "@react-native-masked-view/masked-view": "0.3.1", "@react-native-picker/picker": "2.11.0", "@react-navigation/native": "7.0.14", @@ -33,6 +33,7 @@ "react-native-localize": "3.2.1", "react-native-pager-view": "6.4.1", "react-native-permissions": "4.1.5", + "react-native-push-notification": "8.1.1", "react-native-reanimated": "3.16.1", "react-native-safe-area-context": "5.2.0", "react-native-schedule-exact-alarm-permission": "^0.1.3", @@ -1783,9 +1784,9 @@ } }, "node_modules/@mendix/native": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/@mendix/native/-/native-9.2.1.tgz", - "integrity": "sha512-c1X409ZPa5N6eO2xNGH9UriIlPxfnPl+k7hNeZYx9pwXMjQobZ6769+7hxzxcX4Z4kS4XYYjsG6POst3gYpHjQ==" + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@mendix/native/-/native-9.2.0.tgz", + "integrity": "sha512-mzq+WCmuGW06PbSYCOd/lZ7Ub0mkVvN2nuwPJA2bwgamePu/kSHeDcf8jP+kazqpknIPs4al6JM7GwFPgjQa4g==" }, "node_modules/@mendix/native-mobile-toolkit": { "version": "1.0.127", @@ -1844,15 +1845,6 @@ "node": ">= 8" } }, - "node_modules/@notifee/react-native": { - "version": "9.1.8", - "resolved": "https://registry.npmjs.org/@notifee/react-native/-/react-native-9.1.8.tgz", - "integrity": "sha512-Az/dueoPerJsbbjRxu8a558wKY+gONUrfoy3Hs++5OqbeMsR0dYe6P+4oN6twrLFyzAhEA1tEoZRvQTFDRmvQg==", - "license": "Apache-2.0", - "peerDependencies": { - "react-native": "*" - } - }, "node_modules/@op-engineering/op-sqlite": { "version": "9.2.7", "resolved": "https://registry.npmjs.org/@op-engineering/op-sqlite/-/op-sqlite-9.2.7.tgz", @@ -2455,6 +2447,18 @@ } } }, + "node_modules/@react-native-community/push-notification-ios": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@react-native-community/push-notification-ios/-/push-notification-ios-1.10.1.tgz", + "integrity": "sha512-k6bZWUKLif4GjenyTD3aQLwA2VT3bNmt22INO/34lexnpmqkPDZF7nreqbckTHG0Zso9wDTe4N/AZJUC/d8iRg==", + "dependencies": { + "invariant": "^2.2.4" + }, + "peerDependencies": { + "react": ">=16.6.3", + "react-native": ">=0.58.4" + } + }, "node_modules/@react-native-masked-view/masked-view": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/@react-native-masked-view/masked-view/-/masked-view-0.3.1.tgz", @@ -7772,6 +7776,15 @@ } } }, + "node_modules/react-native-push-notification": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/react-native-push-notification/-/react-native-push-notification-8.1.1.tgz", + "integrity": "sha512-XpBtG/w+a6WXTxu6l1dNYyTiHnbgnvjoc3KxPTxYkaIABRmvuJZkFxqruyGvfCw7ELAlZEAJO+dthdTabCe1XA==", + "peerDependencies": { + "@react-native-community/push-notification-ios": "^1.10.1", + "react-native": ">=0.33" + } + }, "node_modules/react-native-reanimated": { "version": "3.16.1", "resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-3.16.1.tgz", diff --git a/package.json b/package.json index 988d591db..f2b78c0a7 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,7 @@ }, "dependencies": { "@gorhom/bottom-sheet": "^5.1.1", - "@mendix/native": "9.2.1", - "@notifee/react-native": "9.1.8", + "@mendix/native": "9.2.0", "@op-engineering/op-sqlite": "9.2.7", "@react-native-async-storage/async-storage": "2.0.0", "@react-native-camera-roll/camera-roll": "7.4.0", @@ -17,6 +16,7 @@ "@react-native-community/cli-platform-android": "16.0.2", "@react-native-community/cli-platform-ios": "16.0.2", "@react-native-community/datetimepicker": "8.2.0", + "@react-native-community/push-notification-ios": "1.10.1", "@react-native-masked-view/masked-view": "0.3.1", "@react-native-picker/picker": "2.11.0", "@react-navigation/native": "7.0.14", @@ -31,6 +31,7 @@ "react-native-localize": "3.2.1", "react-native-pager-view": "6.4.1", "react-native-permissions": "4.1.5", + "react-native-push-notification": "8.1.1", "react-native-reanimated": "3.16.1", "react-native-safe-area-context": "5.2.0", "react-native-schedule-exact-alarm-permission": "^0.1.3", diff --git a/patches/react-native-push-notification+8.1.1.patch b/patches/react-native-push-notification+8.1.1.patch new file mode 100644 index 000000000..cab3f8645 --- /dev/null +++ b/patches/react-native-push-notification+8.1.1.patch @@ -0,0 +1,17 @@ +diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java +index 248ff08..0ab1b34 100644 +--- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java ++++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java +@@ -171,6 +171,12 @@ public class RNPushNotificationHelper { + return; + } + ++ // call canScheduleExactAlarms to confirm the user has allowed alarms to be set. otherwise, ++ // attempting to set an alarm below will crash the app! ++ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !getAlarmManager().canScheduleExactAlarms()) { ++ return; ++ } ++ + Log.d(LOG_TAG, String.format("Setting a notification with id %s at time %s", + bundle.getString("id"), Long.toString(fireDate))); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {