From 03b92edfa9de0e5bcfa34388da3b9ffe8074daf2 Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Tue, 5 Jan 2021 22:47:39 -0500 Subject: [PATCH] feat(apple): build framework for tvos and watchos (+ simulators) these framework artifacts are untested but do in general seem in harmony with the tvOS and watchOS platforms after the #if/#endif precompiler removal of areas those OSs don't support (tvOS just appears to show a badge and allow data payloads and that's it, for instance, watchOS doesn't have settings) --- .../NotifeeCore+NSNotificationCenter.m | 2 + .../NotifeeCore+UNUserNotificationCenter.m | 22 ++++++-- ios/NotifeeCore/NotifeeCore.m | 56 ++++++++++++++++--- ios/NotifeeCore/NotifeeCoreUtil.m | 20 +++++++ ios/NotifeeCore/Private/NotifeeCoreUtil.h | 8 ++- ios/NotifeeCore/Public/NotifeeCore.h | 10 ++-- ios/build_xcframework.sh | 32 +++++++++++ 7 files changed, 132 insertions(+), 18 deletions(-) diff --git a/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m b/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m index f90a1f59d..d26fad7d5 100644 --- a/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m +++ b/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m @@ -27,11 +27,13 @@ - (void)observe { NotifeeCoreNSNotificationCenter *strongSelf = weakSelf; // Application // ObjC -> Initialize other delegates & observers +#if !TARGET_OS_WATCH [[NSNotificationCenter defaultCenter] addObserver:strongSelf selector:@selector(application_onDidFinishLaunchingNotification:) name:UIApplicationDidFinishLaunchingNotification object:nil]; +#endif [[NSNotificationCenter defaultCenter] addObserver:strongSelf selector:@selector(messaging_didReceiveRemoteNotification:) diff --git a/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m b/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m index 55a816e4b..0a537d62d 100644 --- a/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +++ b/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m @@ -70,8 +70,10 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler: (void (^)(UNNotificationPresentationOptions options))completionHandler { - NSDictionary *notifeeNotification = - notification.request.content.userInfo[kNotifeeUserInfoNotification]; + NSDictionary *notifeeNotification = nil; +#if !TARGET_OS_TV + notifeeNotification = notification.request.content.userInfo[kNotifeeUserInfoNotification]; +#endif // we only care about notifications created through notifee if (notifeeNotification != nil) { @@ -95,7 +97,11 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center presentationOptions |= UNNotificationPresentationOptionAlert; } - NSDictionary *notifeeTrigger = notification.request.content.userInfo[kNotifeeUserInfoTrigger]; + NSDictionary *notifeeTrigger = nil; +#if !TARGET_OS_TV + notifeeTrigger = notification.request.content.userInfo[kNotifeeUserInfoTrigger]; +#endif + if (notifeeTrigger != nil) { // post DELIVERED event [[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:@{ @@ -118,6 +124,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center // The method will be called when the user responded to the notification by opening the application, // dismissing the notification or choosing a UNNotificationAction. The delegate must be set before // the application returns from application:didFinishLaunchingWithOptions:. +#if !TARGET_OS_TV - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { @@ -188,12 +195,19 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center withCompletionHandler:completionHandler]; } } +#endif - (void)userNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(nullable UNNotification *)notification { +#if !TARGET_OS_TV && !TARGET_OS_WATCH if (_originalDelegate != nil && originalUNCDelegateRespondsTo.openSettingsForNotification) { - [_originalDelegate userNotificationCenter:center openSettingsForNotification:notification]; + if (@available(iOS 12.0, *)) { + [_originalDelegate userNotificationCenter:center openSettingsForNotification:notification]; + } else { + // Fallback on earlier versions + } } +#endif } @end diff --git a/ios/NotifeeCore/NotifeeCore.m b/ios/NotifeeCore/NotifeeCore.m index 439bb5e6d..fc923e836 100644 --- a/ios/NotifeeCore/NotifeeCore.m +++ b/ios/NotifeeCore/NotifeeCore.m @@ -31,8 +31,11 @@ + (void)cancelNotification:(NSString *)notificationId withNotificationType: (NSI UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; // cancel displayed notification if (notificationType == NotifeeCoreNotificationTypeDisplayed || - notificationType == NotifeeCoreNotificationTypeAll) + notificationType == NotifeeCoreNotificationTypeAll) { +#if !TARGET_OS_TV [center removeDeliveredNotificationsWithIdentifiers:@[ notificationId ]]; +#endif + } // cancel trigger notification if (notificationType == NotifeeCoreNotificationTypeTrigger || @@ -52,8 +55,11 @@ + (void)cancelAllNotifications:(NSInteger)notificationType withBlock:(notifeeMet // cancel displayed notifications if (notificationType == NotifeeCoreNotificationTypeDisplayed || - notificationType == NotifeeCoreNotificationTypeAll) + notificationType == NotifeeCoreNotificationTypeAll) { +#if !TARGET_OS_TV [center removeAllDeliveredNotifications]; +#endif + } // cancel trigger notifications if (notificationType == NotifeeCoreNotificationTypeTrigger || @@ -159,6 +165,10 @@ + (UNMutableNotificationContent *)buildNotificationContent:(NSDictionary *)notif NSDictionary *iosDict = notification[@"ios"]; UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; + // badgeCount - nil is an acceptable value so no need to check key existence + content.badge = iosDict[@"badgeCount"]; + +#if !TARGET_OS_TV // title if (notification[@"title"] != nil) { content.title = notification[@"title"]; @@ -185,9 +195,6 @@ + (UNMutableNotificationContent *)buildNotificationContent:(NSDictionary *)notif content.userInfo = userInfo; - // badgeCount - nil is an acceptable value so no need to check key existence - content.badge = iosDict[@"badgeCount"]; - // categoryId if (iosDict[@"categoryId"] != nil) { content.categoryIdentifier = iosDict[@"categoryId"]; @@ -205,7 +212,9 @@ + (UNMutableNotificationContent *)buildNotificationContent:(NSDictionary *)notif NSNumber *criticalSoundVolume = iosDict[@"criticalVolume"]; NSString *soundName = iosDict[@"sound"] != nil ? iosDict[@"sound"] : @"default"; +#if !TARGET_OS_WATCH if ([soundName isEqualToString:@"default"]) { +#endif if (criticalSound) { if (@available(iOS 12.0, *)) { if (criticalSoundVolume != nil) { @@ -220,6 +229,7 @@ + (UNMutableNotificationContent *)buildNotificationContent:(NSDictionary *)notif } else { notificationSound = [UNNotificationSound defaultSound]; } +#if !TARGET_OS_WATCH } else { if (criticalSound) { if (@available(iOS 12.0, *)) { @@ -237,16 +247,21 @@ + (UNMutableNotificationContent *)buildNotificationContent:(NSDictionary *)notif notificationSound = [UNNotificationSound soundNamed:soundName]; } } +#endif content.sound = notificationSound; } else if (iosDict[@"sound"] != nil) { UNNotificationSound *notificationSound; NSString *soundName = iosDict[@"sound"]; +#if !TARGET_OS_WATCH if ([soundName isEqualToString:@"default"]) { +#endif notificationSound = [UNNotificationSound defaultSound]; +#if !TARGET_OS_WATCH } else { notificationSound = [UNNotificationSound soundNamed:soundName]; } +#endif content.sound = notificationSound; @@ -257,6 +272,7 @@ + (UNMutableNotificationContent *)buildNotificationContent:(NSDictionary *)notif content.threadIdentifier = iosDict[@"threadId"]; } +#if !TARGET_OS_WATCH if (@available(iOS 12.0, *)) { // summaryArgument if (iosDict[@"summaryArgument"] != nil) { @@ -268,6 +284,7 @@ + (UNMutableNotificationContent *)buildNotificationContent:(NSDictionary *)notif content.summaryArgumentCount = [iosDict[@"summaryArgumentCount"] unsignedIntValue]; } } +#endif if (@available(iOS 13.0, *)) { // targetContentId @@ -281,10 +298,12 @@ + (UNMutableNotificationContent *)buildNotificationContent:(NSDictionary *)notif content.attachments = [NotifeeCoreUtil notificationAttachmentsFromDictionaryArray:iosDict[@"attachments"]]; } +#endif return content; } +#if !TARGET_OS_TV + (void)getNotificationCategories:(notifeeMethodNSArrayBlock)block { UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center getNotificationCategoriesWithCompletionHandler:^( @@ -298,6 +317,7 @@ + (void)getNotificationCategories:(notifeeMethodNSArrayBlock)block { categoryDictionary[@"allowInCarPlay"] = @(((notificationCategory.options & UNNotificationCategoryOptionAllowInCarPlay) != 0)); +#if !TARGET_OS_WATCH if (@available(iOS 11.0, *)) { categoryDictionary[@"hiddenPreviewsShowTitle"] = @(((notificationCategory.options & @@ -310,8 +330,10 @@ + (void)getNotificationCategories:(notifeeMethodNSArrayBlock)block { notificationCategory.hiddenPreviewsBodyPlaceholder; } } else { +#endif categoryDictionary[@"hiddenPreviewsShowTitle"] = @(NO); categoryDictionary[@"hiddenPreviewsShowSubtitle"] = @(NO); +#if !TARGET_OS_WATCH } if (@available(iOS 12.0, *)) { @@ -319,6 +341,7 @@ + (void)getNotificationCategories:(notifeeMethodNSArrayBlock)block { categoryDictionary[@"summaryFormat"] = notificationCategory.categorySummaryFormat; } } +#endif if (@available(iOS 13.0, *)) { categoryDictionary[@"allowAnnouncement"] = @( @@ -353,8 +376,6 @@ + (void)setNotificationCategories:(NSArray *)categories UNNotificationCategory *category; NSString *id = categoryDictionary[@"id"]; - NSString *summaryFormat = categoryDictionary[@"summaryFormat"]; - NSString *bodyPlaceHolder = categoryDictionary[@"hiddenPreviewsBodyPlaceholder"]; NSArray *actions = [NotifeeCoreUtil notificationActionsFromDictionaryArray:categoryDictionary[@"actions"]]; @@ -367,6 +388,7 @@ + (void)setNotificationCategories:(NSArray *)categories options |= UNNotificationCategoryOptionAllowInCarPlay; } +#if !TARGET_OS_WATCH if (@available(iOS 11.0, *)) { if ([categoryDictionary[@"hiddenPreviewsShowTitle"] isEqual:@(YES)]) { options |= UNNotificationCategoryOptionHiddenPreviewsShowTitle; @@ -376,6 +398,7 @@ + (void)setNotificationCategories:(NSArray *)categories options |= UNNotificationCategoryOptionHiddenPreviewsShowSubtitle; } } +#endif if (@available(iOS 13.0, *)) { if ([categoryDictionary[@"allowAnnouncement"] isEqual:@(YES)]) { @@ -383,6 +406,9 @@ + (void)setNotificationCategories:(NSArray *)categories } } +#if !TARGET_OS_WATCH + NSString *summaryFormat = categoryDictionary[@"summaryFormat"]; + NSString *bodyPlaceHolder = categoryDictionary[@"hiddenPreviewsBodyPlaceholder"]; if (@available(iOS 12.0, *)) { category = [UNNotificationCategory categoryWithIdentifier:id actions:actions @@ -397,11 +423,14 @@ + (void)setNotificationCategories:(NSArray *)categories hiddenPreviewsBodyPlaceholder:bodyPlaceHolder options:options]; } else { +#endif category = [UNNotificationCategory categoryWithIdentifier:id actions:actions intentIdentifiers:intentIdentifiers options:options]; +#if !TARGET_OS_WATCH } +#endif [UNNotificationCategories addObject:category]; } @@ -410,6 +439,7 @@ + (void)setNotificationCategories:(NSArray *)categories [center setNotificationCategories:UNNotificationCategories]; block(nil); } +#endif /** * Request UNAuthorizationOptions for user notifications. @@ -448,11 +478,13 @@ + (void)requestPermission:(NSDictionary *)permissions } } +#if !TARGET_OS_TV if ([permissions[@"announcement"] isEqual:@(YES)]) { if (@available(iOS 13.0, *)) { options |= UNAuthorizationOptionAnnouncement; } } +#endif if ([permissions[@"carPlay"] isEqual:@(YES)]) { options |= UNAuthorizationOptionCarPlay; @@ -504,6 +536,7 @@ + (void)getNotificationSettings:(notifeeMethodNSDictionaryBlock)block { } } +#if !TARGET_OS_TV && !TARGET_OS_WATCH NSNumber *showPreviews = @-1; if (@available(iOS 11.0, *)) { if (settings.showPreviewsSetting == UNShowPreviewsSettingNever) { @@ -550,6 +583,7 @@ + (void)getNotificationSettings:(notifeeMethodNSDictionaryBlock)block { [NotifeeCoreUtil numberForUNNotificationSetting:settings.lockScreenSetting]; settingsDictionary[@"notificationCenter"] = [NotifeeCoreUtil numberForUNNotificationSetting:settings.notificationCenterSetting]; +#endif block(nil, settingsDictionary); }]; } @@ -559,22 +593,29 @@ + (void)getInitialNotification:(notifeeMethodNSDictionaryBlock)block { } + (void)setBadgeCount:(NSInteger)count withBlock:(notifeeMethodVoidBlock)block { +#if !TARGET_OS_WATCH [[UIApplication sharedApplication] setApplicationIconBadgeNumber:count]; +#endif block(nil); } + (void)getBadgeCount:(notifeeMethodNSIntegerBlock)block { +#if !TARGET_OS_WATCH block(nil, [UIApplication sharedApplication].applicationIconBadgeNumber); +#endif } + (void)incrementBadgeCount:(NSInteger)incrementBy withBlock:(notifeeMethodVoidBlock)block { +#if !TARGET_OS_WATCH NSInteger currentCount = [UIApplication sharedApplication].applicationIconBadgeNumber; NSInteger newCount = currentCount + incrementBy; [[UIApplication sharedApplication] setApplicationIconBadgeNumber:newCount]; +#endif block(nil); } + (void)decrementBadgeCount:(NSInteger)decrementBy withBlock:(notifeeMethodVoidBlock)block { +#if !TARGET_OS_WATCH NSInteger currentCount = [UIApplication sharedApplication].applicationIconBadgeNumber; NSInteger newCount = currentCount - decrementBy; @@ -583,6 +624,7 @@ + (void)decrementBadgeCount:(NSInteger)decrementBy withBlock:(notifeeMethodVoidB } [[UIApplication sharedApplication] setApplicationIconBadgeNumber:newCount]; +#endif block(nil); } diff --git a/ios/NotifeeCore/NotifeeCoreUtil.m b/ios/NotifeeCore/NotifeeCoreUtil.m index 6b585afdc..a71fbd629 100644 --- a/ios/NotifeeCore/NotifeeCoreUtil.m +++ b/ios/NotifeeCore/NotifeeCoreUtil.m @@ -26,6 +26,7 @@ + (NSNumber *)numberForUNNotificationSetting:(UNNotificationSetting)setting { return asNumber; } +#if !TARGET_OS_TV + (NSMutableArray *)notificationActionsToDictionaryArray: (NSArray *)notificationActions { NSMutableArray *notificationActionDicts = [[NSMutableArray alloc] init]; @@ -177,6 +178,7 @@ + (UNNotificationAttachment *)attachmentFromDictionary:(NSDictionary *)attachmen NSLog(@"NotifeeCore: Unable to resolve url for attachment: %@", attachmentDict); return nil; } +#endif /* * Downloads a media file, syncronously to the NSCachesDirectory @@ -236,6 +238,7 @@ + (NSURL *)downloadMediaSynchronously:(NSString *)urlString { } } +#if !TARGET_OS_TV /** * Returns a NSDictionary representation of options related to the attached file * @@ -269,6 +272,7 @@ + (NSDictionary *)attachmentOptionsFromDictionary:(NSDictionary *)optionsDict { return options; } +#endif /** * Returns an UNNotificationTrigger from NSDictionary representing a trigger @@ -374,6 +378,7 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger (NSArray *)identifiers { NSMutableArray *intentIdentifiers = [[NSMutableArray alloc] init]; +#if !TARGET_OS_TV for (NSString *identifier in identifiers) { if ([identifier isEqualToString:INStartAudioCallIntentIdentifier]) { // IOSIntentIdentifier.START_AUDIO_CALL @@ -384,6 +389,7 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger } else if ([identifier isEqualToString:INSearchCallHistoryIntentIdentifier]) { // IOSIntentIdentifier.SEARCH_CALL_HISTORY [intentIdentifiers addObject:@2]; +#if !TARGET_OS_WATCH } else if ([identifier isEqualToString:INSetAudioSourceInCarIntentIdentifier]) { // IOSIntentIdentifier.SET_AUDIO_SOURCE_IN_CAR [intentIdentifiers addObject:@3]; @@ -402,6 +408,7 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger } else if ([identifier isEqualToString:INSaveProfileInCarIntentIdentifier]) { // IOSIntentIdentifier.SAVE_PROFILE_IN_CAR [intentIdentifiers addObject:@8]; +#endif } else if ([identifier isEqualToString:INStartWorkoutIntentIdentifier]) { // IOSIntentIdentifier.START_WORKOUT [intentIdentifiers addObject:@9]; @@ -417,18 +424,22 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger } else if ([identifier isEqualToString:INResumeWorkoutIntentIdentifier]) { // IOSIntentIdentifier.RESUME_WORKOUT [intentIdentifiers addObject:@13]; +#if !TARGET_OS_WATCH } else if ([identifier isEqualToString:INSetRadioStationIntentIdentifier]) { // IOSIntentIdentifier.SET_RADIO_STATION [intentIdentifiers addObject:@14]; +#endif } else if ([identifier isEqualToString:INSendMessageIntentIdentifier]) { // IOSIntentIdentifier.SEND_MESSAGE [intentIdentifiers addObject:@15]; } else if ([identifier isEqualToString:INSearchForMessagesIntentIdentifier]) { // IOSIntentIdentifier.SEARCH_FOR_MESSAGES [intentIdentifiers addObject:@16]; +#if !TARGET_OS_WATCH } else if ([identifier isEqualToString:INSetMessageAttributeIntentIdentifier]) { // IOSIntentIdentifier.SET_MESSAGE_ATTRIBUTE [intentIdentifiers addObject:@17]; +#endif } else if ([identifier isEqualToString:INSendPaymentIntentIdentifier]) { // IOSIntentIdentifier.SEND_PAYMENT [intentIdentifiers addObject:@18]; @@ -452,6 +463,7 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger [intentIdentifiers addObject:@24]; } } +#endif return intentIdentifiers; } @@ -460,6 +472,7 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger (NSArray *)identifiers { NSMutableArray *intentIdentifiers = [[NSMutableArray alloc] init]; +#if !TARGET_OS_TV for (NSNumber *identifier in identifiers) { if ([identifier isEqualToNumber:@0]) { // IOSIntentIdentifier.START_AUDIO_CALL @@ -470,6 +483,7 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger } else if ([identifier isEqualToNumber:@2]) { // IOSIntentIdentifier.SEARCH_CALL_HISTORY [intentIdentifiers addObject:INSearchCallHistoryIntentIdentifier]; +#if !TARGET_OS_WATCH } else if ([identifier isEqualToNumber:@3]) { // IOSIntentIdentifier.SET_AUDIO_SOURCE_IN_CAR [intentIdentifiers addObject:INSetAudioSourceInCarIntentIdentifier]; @@ -488,6 +502,7 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger } else if ([identifier isEqualToNumber:@8]) { // IOSIntentIdentifier.SAVE_PROFILE_IN_CAR [intentIdentifiers addObject:INSaveProfileInCarIntentIdentifier]; +#endif } else if ([identifier isEqualToNumber:@9]) { // IOSIntentIdentifier.START_WORKOUT [intentIdentifiers addObject:INStartWorkoutIntentIdentifier]; @@ -503,18 +518,22 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger } else if ([identifier isEqualToNumber:@13]) { // IOSIntentIdentifier.RESUME_WORKOUT [intentIdentifiers addObject:INResumeWorkoutIntentIdentifier]; +#if !TARGET_OS_WATCH } else if ([identifier isEqualToNumber:@14]) { // IOSIntentIdentifier.SET_RADIO_STATION [intentIdentifiers addObject:INSetRadioStationIntentIdentifier]; +#endif } else if ([identifier isEqualToNumber:@15]) { // IOSIntentIdentifier.SEND_MESSAGE [intentIdentifiers addObject:INSendMessageIntentIdentifier]; } else if ([identifier isEqualToNumber:@16]) { // IOSIntentIdentifier.SEARCH_FOR_MESSAGES [intentIdentifiers addObject:INSearchForMessagesIntentIdentifier]; +#if !TARGET_OS_WATCH } else if ([identifier isEqualToNumber:@17]) { // IOSIntentIdentifier.SET_MESSAGE_ATTRIBUTE [intentIdentifiers addObject:INSetMessageAttributeIntentIdentifier]; +#endif } else if ([identifier isEqualToNumber:@18]) { // IOSIntentIdentifier.SEND_PAYMENT [intentIdentifiers addObject:INSendPaymentIntentIdentifier]; @@ -538,6 +557,7 @@ + (UNNotificationTrigger *)intervalTriggerFromDictionary:(NSDictionary *)trigger [intentIdentifiers addObject:INGetRideStatusIntentIdentifier]; } } +#endif return intentIdentifiers; } diff --git a/ios/NotifeeCore/Private/NotifeeCoreUtil.h b/ios/NotifeeCore/Private/NotifeeCoreUtil.h index 5d9337688..c11195a59 100644 --- a/ios/NotifeeCore/Private/NotifeeCoreUtil.h +++ b/ios/NotifeeCore/Private/NotifeeCoreUtil.h @@ -29,20 +29,22 @@ typedef NS_ENUM(NSInteger, NotifeeCoreTriggerType) { // Enum representing repeat frequency for TimestampTrigger typedef NS_ENUM(NSInteger, NotifeeCoreRepeatFrequency) { - NotifeeCoreRepeatFrequencyHourly = 0, - NotifeeCoreRepeatFrequencyDaily = 1, - NotifeeCoreRepeatFrequencyWeekly = 2 + NotifeeCoreRepeatFrequencyHourly = 0, + NotifeeCoreRepeatFrequencyDaily = 1, + NotifeeCoreRepeatFrequencyWeekly = 2 }; @interface NotifeeCoreUtil : NSObject + (NSNumber *)numberForUNNotificationSetting:(UNNotificationSetting)setting; +#if !TARGET_OS_TV + (NSMutableArray *)notificationActionsToDictionaryArray:(NSArray *)notificationActions; + (NSMutableArray *)notificationActionsFromDictionaryArray:(NSArray *)actionDictionaries; + (NSMutableArray *)notificationAttachmentsFromDictionaryArray:(NSArray *)attachmentDictionaries; +#endif + (NSMutableArray *)intentIdentifiersFromStringArray:(NSArray *)identifiers; diff --git a/ios/NotifeeCore/Public/NotifeeCore.h b/ios/NotifeeCore/Public/NotifeeCore.h index 4e8e7af7b..5f6638098 100644 --- a/ios/NotifeeCore/Public/NotifeeCore.h +++ b/ios/NotifeeCore/Public/NotifeeCore.h @@ -45,29 +45,31 @@ typedef NS_ENUM(NSInteger, NotifeeCoreEventType) { @protocol NotifeeCoreDelegate @optional -- (void) didReceiveNotifeeCoreEvent:(NSDictionary *_Nonnull)event; +- (void)didReceiveNotifeeCoreEvent:(NSDictionary *_Nonnull)event; @end @interface NotifeeCore : NSObject -+ (void)setCoreDelegate:(id )coreDelegate; ++ (void)setCoreDelegate:(id)coreDelegate; -+ (void)cancelNotification:(NSString *)notificationId withNotificationType: (NSInteger)notificationType withBlock:(notifeeMethodVoidBlock)block; ++ (void)cancelNotification:(NSString *)notificationId withNotificationType:(NSInteger)notificationType withBlock:(notifeeMethodVoidBlock)block; + (void)cancelAllNotifications:(NSInteger)notificationType withBlock:(notifeeMethodVoidBlock)block; + (void)displayNotification:(NSDictionary *)notification withBlock:(notifeeMethodVoidBlock)block; -+ (void)createTriggerNotification:(NSDictionary *)notification withTrigger: (NSDictionary *)trigger withBlock:(notifeeMethodVoidBlock)block; ++ (void)createTriggerNotification:(NSDictionary *)notification withTrigger:(NSDictionary *)trigger withBlock:(notifeeMethodVoidBlock)block; + (void)getTriggerNotificationIds:(notifeeMethodNSArrayBlock)block; + (void)requestPermission:(NSDictionary *)permissions withBlock:(notifeeMethodNSDictionaryBlock)block; +#if !TARGET_OS_TV + (void)getNotificationCategories:(notifeeMethodNSArrayBlock)block; + (void)setNotificationCategories:(NSArray *)categories withBlock:(notifeeMethodVoidBlock)block; +#endif + (void)getNotificationSettings:(notifeeMethodNSDictionaryBlock)block; diff --git a/ios/build_xcframework.sh b/ios/build_xcframework.sh index a597d96d1..eb5049ac8 100755 --- a/ios/build_xcframework.sh +++ b/ios/build_xcframework.sh @@ -9,6 +9,10 @@ BUILD_SCHEME="NotifeeCore" IOS_SIMULATOR_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/iOS_simulator.xcarchive" IOS_DEVICE_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/iOS.xcarchive" CATALYST_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/catalyst.xcarchive" +TVOS_SIMULATOR_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/tvOS_simulator.xcarchive" +TVOS_DEVICE_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/tvOS.xcarchive" +WATCHOS_SIMULATOR_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/watchOS_simulator.xcarchive" +WATCHOS_DEVICE_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/watchOS.xcarchive" OUTPUT_FOLDER=${WORKING_DIR}/../packages/react-native/ios/ rm -rf "${WORKING_DIR:?}/${FRAMEWORK_FOLDER_NAME}" @@ -33,16 +37,44 @@ xcodebuild archive -workspace "./${FRAMEWORK_NAME}.xcworkspace" -scheme ${BUILD_ -destination='platform=macOS,arch=x86_64,variant=Mac Catalyst' -archivePath "${CATALYST_ARCHIVE_PATH}" \ SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty -k +echo "Archiving for tvOS Simulator" +xcodebuild archive -workspace "./${FRAMEWORK_NAME}.xcworkspace" -scheme ${BUILD_SCHEME} -configuration Release \ + -destination="tvOS Simulator" -archivePath "${TVOS_SIMULATOR_ARCHIVE_PATH}" \ + -sdk appletvsimulator SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty -k + +echo "Archiving for tvOS" +xcodebuild archive -workspace "./${FRAMEWORK_NAME}.xcworkspace" -scheme ${BUILD_SCHEME} -configuration Release \ + -destination="tvOS" -archivePath "${TVOS_DEVICE_ARCHIVE_PATH}" \ + -sdk appletvos SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty -k + +echo "Archiving for watchOS Simulator" +xcodebuild archive -workspace "./${FRAMEWORK_NAME}.xcworkspace" -scheme ${BUILD_SCHEME} -configuration Release \ + -destination="watchOS Simulator" -archivePath "${WATCHOS_SIMULATOR_ARCHIVE_PATH}" \ + -sdk watchsimulator SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty -k + +echo "Archiving for watchOS" +xcodebuild archive -workspace "./${FRAMEWORK_NAME}.xcworkspace" -scheme ${BUILD_SCHEME} -configuration Release \ + -destination="watchOS" -archivePath "${WATCHOS_DEVICE_ARCHIVE_PATH}" \ + -sdk watchos SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty -k + echo "Packaging archives into ${FRAMEWORK_NAME}.xcframework bundle" xcodebuild -create-xcframework \ -framework "${IOS_SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \ -framework "${IOS_DEVICE_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \ -framework "${CATALYST_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \ + -framework "${TVOS_SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \ + -framework "${TVOS_DEVICE_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \ + -framework "${WATCHOS_SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \ + -framework "${WATCHOS_DEVICE_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \ -output "${FRAMEWORK_PATH}" | xcpretty rm -rf "${IOS_SIMULATOR_ARCHIVE_PATH}" rm -rf "${IOS_DEVICE_ARCHIVE_PATH}" rm -rf "${CATALYST_ARCHIVE_PATH}" +rm -rf "${TVOS_SIMULATOR_ARCHIVE_PATH}" +rm -rf "${TVOS_DEVICE_ARCHIVE_PATH}" +rm -rf "${WATCHOS_SIMULATOR_ARCHIVE_PATH}" +rm -rf "${WATCHOS_DEVICE_ARCHIVE_PATH}" # Catalyst framework directory structure flattening step 1: # - Copy the framework in a specific way: de-referencing symbolic links on purpose