From f1f15d9955c9a457be7b86f48587dab600768ea1 Mon Sep 17 00:00:00 2001 From: Nan Date: Tue, 25 Jun 2024 15:52:47 -0700 Subject: [PATCH 1/2] Ignore live activities code for mac catalyst * These codes reference `OneSignalLiveActivitiesManagerImpl` directly which is in a module not available to Mac Catalyst due to ActivityKit dependency * Therefore, it caused build failures for Mac Catalyst. * Live Activities does not work for Mac anyway, so just ignore these methods. --- src/ios/OneSignalPush.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ios/OneSignalPush.m b/src/ios/OneSignalPush.m index 681b0eda..0b618eaf 100644 --- a/src/ios/OneSignalPush.m +++ b/src/ios/OneSignalPush.m @@ -636,6 +636,7 @@ - (void)exitLiveActivity:(CDVInvokedUrlCommand *)command { } - (void)setPushToStartToken:(CDVInvokedUrlCommand *)command { + #if !TARGET_OS_MACCATALYST NSString *activityType = command.arguments[0]; NSString *token = command.arguments[1]; NSError* err=nil; @@ -648,9 +649,11 @@ - (void)setPushToStartToken:(CDVInvokedUrlCommand *)command { } else { [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setPushToStartToken on iOS < 17.2"]]; } + #endif } - (void)removePushToStartToken:(CDVInvokedUrlCommand *)command { + #if !TARGET_OS_MACCATALYST NSString *activityType = command.arguments[0]; NSError* err=nil; @@ -662,9 +665,11 @@ - (void)removePushToStartToken:(CDVInvokedUrlCommand *)command { } else { [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot removePushToStartToken on iOS < 17.2"]]; } + #endif } - (void)setupDefaultLiveActivity:(CDVInvokedUrlCommand *)command { + #if !TARGET_OS_MACCATALYST NSDictionary *options = command.arguments[0]; LiveActivitySetupOptions *laOptions = nil; @@ -679,9 +684,11 @@ - (void)setupDefaultLiveActivity:(CDVInvokedUrlCommand *)command { } else { [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setupDefault on iOS < 16.1"]]; } + #endif } - (void)startDefaultLiveActivity:(CDVInvokedUrlCommand *)command { + #if !TARGET_OS_MACCATALYST NSString *activityId = command.arguments[0]; NSDictionary *attributes = command.arguments[1]; NSDictionary *content = command.arguments[2]; @@ -691,5 +698,6 @@ - (void)startDefaultLiveActivity:(CDVInvokedUrlCommand *)command { } else { [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot startDefault on iOS < 16.1"]]; } + #endif } @end From 0bbd52bd0295df5a1fb769277e96ff3c30960340 Mon Sep 17 00:00:00 2001 From: Nan Date: Tue, 25 Jun 2024 16:20:31 -0700 Subject: [PATCH 2/2] [dev app] update Live Activities mac catalyst --- .../ios/App/ExampleWidget/ExampleWidgetBundle.swift | 3 ++- .../ios/App/ExampleWidget/ExampleWidgetLiveActivity.swift | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetBundle.swift b/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetBundle.swift index 71407d0a..a0495876 100644 --- a/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetBundle.swift +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetBundle.swift @@ -8,10 +8,11 @@ import WidgetKit import SwiftUI - +#if !targetEnvironment(macCatalyst) @main struct ExampleWidgetBundle: WidgetBundle { var body: some Widget { ExampleWidgetLiveActivity() } } +#endif diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetLiveActivity.swift b/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetLiveActivity.swift index 866ec180..e359a4c7 100644 --- a/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetLiveActivity.swift +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetLiveActivity.swift @@ -6,6 +6,7 @@ // Copyright © 2024 The Chromium Authors. All rights reserved. // +#if !targetEnvironment(macCatalyst) import ActivityKit import WidgetKit import SwiftUI @@ -64,3 +65,4 @@ struct ExampleWidgetLiveActivity: Widget { } } } +#endif