Skip to content

Commit

Permalink
fix: a missing NULL check on new arch iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiangu committed May 4, 2024
1 parent 2d79255 commit 39c7341
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"ios": "react-native run-ios",
"start": "react-native start",
"build:android": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
"build:ios": "cd ios && xcodebuild -workspace LocalNotificationsExample.xcworkspace -scheme LocalNotificationsExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO"
"build:ios": "cd ios && xcodebuild -workspace LocalNotificationsExample.xcworkspace -scheme LocalNotificationsExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
"pod-new-arch": "cd ios && RCT_NEW_ARCH_ENABLED=1 pod install"
},
"dependencies": {
"react": "18.2.0",
Expand Down
21 changes: 14 additions & 7 deletions ios/LocalNotifications.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ @implementation LocalNotifications
reject: (RCTPromiseRejectBlock) reject)
{

[NotificationScheduler
scheduleNotificationWithTitle: notification.title()
body: notification.body()
data: (NSMutableDictionary * _Nullable) notification.data()
scheduleId: notification.id_()
triggerDate: [NSDate dateWithTimeIntervalSince1970: trigger.timestamp() / 1000]
if(notification.title() == NULL) {
NSString *message = [NSString stringWithFormat:@"%@ Title prop is missing.", TAG];
reject(@"error", message, NULL);
return;
}

NSString *scheduleId = [NotificationScheduler
scheduleNotificationWithTitle: notification.title()
body: notification.body()
data: (NSMutableDictionary * _Nullable) notification.data()
scheduleId: notification.id_()
triggerDate: [NSDate dateWithTimeIntervalSince1970: trigger.timestamp() / 1000]
];
resolve(NULL);

resolve(scheduleId);
}

#else
Expand Down

0 comments on commit 39c7341

Please sign in to comment.