From 9a47c853cebe517dd422b77025ebd9bf60cccc06 Mon Sep 17 00:00:00 2001 From: David Stoker Date: Wed, 15 Nov 2017 22:04:11 -0500 Subject: [PATCH] Add iOS version checks to prevent crashes on iOS 8 --- RNNotifications/RNNotifications.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index e82cdf0..8c3a0aa 100644 --- a/RNNotifications/RNNotifications.m +++ b/RNNotifications/RNNotifications.m @@ -62,7 +62,9 @@ RCT_ENUM_CONVERTER(UIUserNotificationActionBehavior, (@{ UIMutableUserNotificationAction* action =[UIMutableUserNotificationAction new]; action.activationMode = [RCTConvert UIUserNotificationActivationMode:details[@"activationMode"]]; - action.behavior = [RCTConvert UIUserNotificationActionBehavior:details[@"behavior"]]; + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) { + action.behavior = [RCTConvert UIUserNotificationActionBehavior:details[@"behavior"]]; + } action.authenticationRequired = [RCTConvert BOOL:details[@"authenticationRequired"]]; action.destructive = [RCTConvert BOOL:details[@"destructive"]]; action.title = [RCTConvert NSString:details[@"title"]]; @@ -100,7 +102,9 @@ RCT_ENUM_CONVERTER(UIUserNotificationActionBehavior, (@{ UILocalNotification* notification = [UILocalNotification new]; notification.fireDate = [RCTConvert NSDate:details[@"fireDate"]]; notification.alertBody = [RCTConvert NSString:details[@"alertBody"]]; - notification.alertTitle = [RCTConvert NSString:details[@"alertTitle"]]; + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.2")) { + notification.alertTitle = [RCTConvert NSString:details[@"alertTitle"]]; + } notification.alertAction = [RCTConvert NSString:details[@"alertAction"]]; notification.soundName = [RCTConvert NSString:details[@"soundName"]] ?: UILocalNotificationDefaultSoundName; if ([RCTConvert BOOL:details[@"silent"]]) { -- 2.26.2