diff --git a/example/IonicCapOneSignal/ios/App/App.xcodeproj/project.pbxproj b/example/IonicCapOneSignal/ios/App/App.xcodeproj/project.pbxproj index a1530ca2..987f62ff 100644 --- a/example/IonicCapOneSignal/ios/App/App.xcodeproj/project.pbxproj +++ b/example/IonicCapOneSignal/ios/App/App.xcodeproj/project.pbxproj @@ -7,7 +7,14 @@ objects = { /* Begin PBXBuildFile section */ + 233AB0E51F2674B91F894E2B /* Pods_ExampleWidgetExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81206892589BDD8D3AD2E4C0 /* Pods_ExampleWidgetExtension.framework */; }; 2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; }; + 4711E13D2BFD3D4800C4D895 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4711E13C2BFD3D4800C4D895 /* WidgetKit.framework */; }; + 4711E13F2BFD3D4800C4D895 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4711E13E2BFD3D4800C4D895 /* SwiftUI.framework */; }; + 4711E1422BFD3D4800C4D895 /* ExampleWidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4711E1412BFD3D4800C4D895 /* ExampleWidgetBundle.swift */; }; + 4711E1442BFD3D4800C4D895 /* ExampleWidgetLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4711E1432BFD3D4800C4D895 /* ExampleWidgetLiveActivity.swift */; }; + 4711E1482BFD3D4900C4D895 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4711E1472BFD3D4900C4D895 /* Assets.xcassets */; }; + 4711E14C2BFD3D4900C4D895 /* ExampleWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 4711E13B2BFD3D4800C4D895 /* ExampleWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */ = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E /* capacitor.config.json */; }; 504EC3081FED79650016851F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC3071FED79650016851F /* AppDelegate.swift */; }; 504EC30D1FED79650016851F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30B1FED79650016851F /* Main.storyboard */; }; @@ -21,6 +28,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 4711E14A2BFD3D4900C4D895 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 504EC2FC1FED79650016851F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 4711E13A2BFD3D4800C4D895; + remoteInfo = ExampleWidgetExtension; + }; CF153A062BEC768C00741F42 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 504EC2FC1FED79650016851F /* Project object */; @@ -38,6 +52,7 @@ dstSubfolderSpec = 13; files = ( CF153A082BEC768C00741F42 /* OneSignalNotificationServiceExtension.appex in Embed Foundation Extensions */, + 4711E14C2BFD3D4900C4D895 /* ExampleWidgetExtension.appex in Embed Foundation Extensions */, ); name = "Embed Foundation Extensions"; runOnlyForDeploymentPostprocessing = 0; @@ -45,7 +60,16 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0CD40CAE3F5EF50D737C2067 /* Pods-ExampleWidgetExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleWidgetExtension.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleWidgetExtension/Pods-ExampleWidgetExtension.release.xcconfig"; sourceTree = ""; }; + 1F3B965497F5BEF67C4BE9C0 /* Pods-ExampleWidgetExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleWidgetExtension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleWidgetExtension/Pods-ExampleWidgetExtension.debug.xcconfig"; sourceTree = ""; }; 2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = ""; }; + 4711E13B2BFD3D4800C4D895 /* ExampleWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ExampleWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 4711E13C2BFD3D4800C4D895 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; + 4711E13E2BFD3D4800C4D895 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; + 4711E1412BFD3D4800C4D895 /* ExampleWidgetBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleWidgetBundle.swift; sourceTree = ""; }; + 4711E1432BFD3D4800C4D895 /* ExampleWidgetLiveActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleWidgetLiveActivity.swift; sourceTree = ""; }; + 4711E1472BFD3D4900C4D895 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 4711E1492BFD3D4900C4D895 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = ""; }; 504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; 504EC3071FED79650016851F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -55,6 +79,7 @@ 504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = ""; }; 58CED0A0F03E31F92FFD8025 /* Pods-OneSignalNotificationServiceExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release.xcconfig"; path = "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release.xcconfig"; sourceTree = ""; }; + 81206892589BDD8D3AD2E4C0 /* Pods_ExampleWidgetExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExampleWidgetExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; }; AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; }; AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = ""; }; BBDA86C51D8754A054E82596 /* Pods_OneSignalNotificationServiceExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OneSignalNotificationServiceExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -69,6 +94,16 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 4711E1382BFD3D4800C4D895 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4711E13F2BFD3D4800C4D895 /* SwiftUI.framework in Frameworks */, + 4711E13D2BFD3D4800C4D895 /* WidgetKit.framework in Frameworks */, + 233AB0E51F2674B91F894E2B /* Pods_ExampleWidgetExtension.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 504EC3011FED79650016851F /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -93,15 +128,30 @@ children = ( AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */, BBDA86C51D8754A054E82596 /* Pods_OneSignalNotificationServiceExtension.framework */, + 4711E13C2BFD3D4800C4D895 /* WidgetKit.framework */, + 4711E13E2BFD3D4800C4D895 /* SwiftUI.framework */, + 81206892589BDD8D3AD2E4C0 /* Pods_ExampleWidgetExtension.framework */, ); name = Frameworks; sourceTree = ""; }; + 4711E1402BFD3D4800C4D895 /* ExampleWidget */ = { + isa = PBXGroup; + children = ( + 4711E1412BFD3D4800C4D895 /* ExampleWidgetBundle.swift */, + 4711E1432BFD3D4800C4D895 /* ExampleWidgetLiveActivity.swift */, + 4711E1472BFD3D4900C4D895 /* Assets.xcassets */, + 4711E1492BFD3D4900C4D895 /* Info.plist */, + ); + path = ExampleWidget; + sourceTree = ""; + }; 504EC2FB1FED79650016851F = { isa = PBXGroup; children = ( 504EC3061FED79650016851F /* App */, CF153A012BEC768C00741F42 /* OneSignalNotificationServiceExtension */, + 4711E1402BFD3D4800C4D895 /* ExampleWidget */, 504EC3051FED79650016851F /* Products */, 7F8756D8B27F46E3366F6CEA /* Pods */, 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */, @@ -113,6 +163,7 @@ children = ( 504EC3041FED79650016851F /* App.app */, CF153A002BEC768C00741F42 /* OneSignalNotificationServiceExtension.appex */, + 4711E13B2BFD3D4800C4D895 /* ExampleWidgetExtension.appex */, ); name = Products; sourceTree = ""; @@ -140,6 +191,8 @@ AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */, EBEAC4EBEBB12957B79AE4D6 /* Pods-OneSignalNotificationServiceExtension.debug.xcconfig */, 58CED0A0F03E31F92FFD8025 /* Pods-OneSignalNotificationServiceExtension.release.xcconfig */, + 1F3B965497F5BEF67C4BE9C0 /* Pods-ExampleWidgetExtension.debug.xcconfig */, + 0CD40CAE3F5EF50D737C2067 /* Pods-ExampleWidgetExtension.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -158,6 +211,24 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 4711E13A2BFD3D4800C4D895 /* ExampleWidgetExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4711E14D2BFD3D4900C4D895 /* Build configuration list for PBXNativeTarget "ExampleWidgetExtension" */; + buildPhases = ( + 66EB456BC3B42EA076C84421 /* [CP] Check Pods Manifest.lock */, + 4711E1372BFD3D4800C4D895 /* Sources */, + 4711E1382BFD3D4800C4D895 /* Frameworks */, + 4711E1392BFD3D4800C4D895 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ExampleWidgetExtension; + productName = ExampleWidgetExtension; + productReference = 4711E13B2BFD3D4800C4D895 /* ExampleWidgetExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; 504EC3031FED79650016851F /* App */ = { isa = PBXNativeTarget; buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */; @@ -173,6 +244,7 @@ ); dependencies = ( CF153A072BEC768C00741F42 /* PBXTargetDependency */, + 4711E14B2BFD3D4900C4D895 /* PBXTargetDependency */, ); name = App; productName = App; @@ -203,9 +275,13 @@ 504EC2FC1FED79650016851F /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0920; + LastSwiftUpdateCheck = 1530; LastUpgradeCheck = 0920; TargetAttributes = { + 4711E13A2BFD3D4800C4D895 = { + CreatedOnToolsVersion = 15.3; + ProvisioningStyle = Automatic; + }; 504EC3031FED79650016851F = { CreatedOnToolsVersion = 9.2; LastSwiftMigration = 1100; @@ -232,11 +308,20 @@ targets = ( 504EC3031FED79650016851F /* App */, CF1539FF2BEC768C00741F42 /* OneSignalNotificationServiceExtension */, + 4711E13A2BFD3D4800C4D895 /* ExampleWidgetExtension */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 4711E1392BFD3D4800C4D895 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4711E1482BFD3D4900C4D895 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 504EC3021FED79650016851F /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -278,6 +363,28 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 66EB456BC3B42EA076C84421 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-ExampleWidgetExtension-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -318,6 +425,15 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 4711E1372BFD3D4800C4D895 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4711E1422BFD3D4800C4D895 /* ExampleWidgetBundle.swift in Sources */, + 4711E1442BFD3D4800C4D895 /* ExampleWidgetLiveActivity.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 504EC3001FED79650016851F /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -337,6 +453,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 4711E14B2BFD3D4900C4D895 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 4711E13A2BFD3D4800C4D895 /* ExampleWidgetExtension */; + targetProxy = 4711E14A2BFD3D4900C4D895 /* PBXContainerItemProxy */; + }; CF153A072BEC768C00741F42 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = CF1539FF2BEC768C00741F42 /* OneSignalNotificationServiceExtension */; @@ -364,6 +485,78 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 4711E14E2BFD3D4900C4D895 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 1F3B965497F5BEF67C4BE9C0 /* Pods-ExampleWidgetExtension.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ExampleWidget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = ExampleWidget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 17.4; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.ExampleWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 4711E14F2BFD3D4900C4D895 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 0CD40CAE3F5EF50D737C2067 /* Pods-ExampleWidgetExtension.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 99SW8E36CT; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ExampleWidget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = ExampleWidget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + IPHONEOS_DEPLOYMENT_TARGET = 17.4; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.ExampleWidget; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; 504EC3141FED79650016851F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -475,6 +668,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; CODE_SIGN_STYLE = Automatic; @@ -497,6 +691,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; CODE_SIGN_STYLE = Automatic; @@ -588,6 +783,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 4711E14D2BFD3D4900C4D895 /* Build configuration list for PBXNativeTarget "ExampleWidgetExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4711E14E2BFD3D4900C4D895 /* Debug */, + 4711E14F2BFD3D4900C4D895 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/example/IonicCapOneSignal/ios/App/App/Info.plist b/example/IonicCapOneSignal/ios/App/App/Info.plist index ca892117..4497c318 100644 --- a/example/IonicCapOneSignal/ios/App/App/Info.plist +++ b/example/IonicCapOneSignal/ios/App/App/Info.plist @@ -22,16 +22,14 @@ $(CURRENT_PROJECT_VERSION) LSRequiresIPhoneOS - UIBackgroundModes - - remote-notification - + NSLocationAlwaysAndWhenInUseUsageDescription + test always and when in use NSLocationUsageDescription Test Location NSLocationWhenInUseUsageDescription Test Location2 - NSLocationAlwaysAndWhenInUseUsageDescription - test always and when in use + NSSupportsLiveActivities + OneSignal_disable_badge_clearing OneSignal_require_privacy_consent diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/AccentColor.colorset/Contents.json b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/AppIcon.appiconset/Contents.json b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..13613e3e --- /dev/null +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/Contents.json b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/Image.imageset/Contents.json b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/Image.imageset/Contents.json new file mode 100644 index 00000000..a19a5492 --- /dev/null +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/Image.imageset/Contents.json @@ -0,0 +1,20 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/Contents.json b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/Contents.json new file mode 100644 index 00000000..0eddeb7c --- /dev/null +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "onesignal-logo.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/onesignal-logo.png b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/onesignal-logo.png new file mode 100644 index 00000000..ba97c7a7 Binary files /dev/null and b/example/IonicCapOneSignal/ios/App/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/onesignal-logo.png differ diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetBundle.swift b/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetBundle.swift new file mode 100644 index 00000000..71407d0a --- /dev/null +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetBundle.swift @@ -0,0 +1,17 @@ +// +// ExampleWidgetBundle.swift +// ExampleWidget +// +// Created by Brian Smith on 4/30/24. +// Copyright © 2024 The Chromium Authors. All rights reserved. +// + +import WidgetKit +import SwiftUI + +@main +struct ExampleWidgetBundle: WidgetBundle { + var body: some Widget { + ExampleWidgetLiveActivity() + } +} diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetLiveActivity.swift b/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetLiveActivity.swift new file mode 100644 index 00000000..866ec180 --- /dev/null +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/ExampleWidgetLiveActivity.swift @@ -0,0 +1,66 @@ +// +// ExampleWidgetLiveActivity.swift +// ExampleWidget +// +// Created by Brian Smith on 4/30/24. +// Copyright © 2024 The Chromium Authors. All rights reserved. +// + +import ActivityKit +import WidgetKit +import SwiftUI +import OneSignalLiveActivities + +struct ExampleWidgetLiveActivity: Widget { + var body: some WidgetConfiguration { + ActivityConfiguration(for: DefaultLiveActivityAttributes.self) { context in + // Lock screen/banner UI goes here\VStack(alignment: .leading) { + VStack { + Spacer() + Text("CORDOVA: " + (context.attributes.data["title"]?.asString() ?? "")).font(.headline) + Spacer() + HStack { + Spacer() + Label { + Text(context.state.data["message"]?.asDict()?["en"]?.asString() ?? "") + } icon: { + Image("onesignaldemo") + .resizable() + .scaledToFit() + .frame(width: 40.0, height: 40.0) + } + Spacer() + } + Text("INT: " + String(context.state.data["intValue"]?.asInt() ?? 0)) + Text("DBL: " + String(context.state.data["doubleValue"]?.asDouble() ?? 0.0)) + Text("BOL: " + String(context.state.data["boolValue"]?.asBool() ?? false)) + Spacer() + } + .activitySystemActionForegroundColor(.black) + .activityBackgroundTint(.white) + } dynamicIsland: { _ in + DynamicIsland { + // Expanded UI goes here. Compose the expanded UI through + // various regions, like leading/trailing/center/bottom + DynamicIslandExpandedRegion(.leading) { + Text("Leading") + } + DynamicIslandExpandedRegion(.trailing) { + Text("Trailing") + } + DynamicIslandExpandedRegion(.bottom) { + Text("Bottom") + // more content + } + } compactLeading: { + Text("L") + } compactTrailing: { + Text("T") + } minimal: { + Text("Min") + } + .widgetURL(URL(string: "http://www.apple.com")) + .keylineTint(Color.red) + } + } +} diff --git a/example/IonicCapOneSignal/ios/App/ExampleWidget/Info.plist b/example/IonicCapOneSignal/ios/App/ExampleWidget/Info.plist new file mode 100644 index 00000000..0f118fb7 --- /dev/null +++ b/example/IonicCapOneSignal/ios/App/ExampleWidget/Info.plist @@ -0,0 +1,11 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/example/IonicCapOneSignal/ios/App/Podfile b/example/IonicCapOneSignal/ios/App/Podfile index 3fc5a5b2..c7e92c6b 100644 --- a/example/IonicCapOneSignal/ios/App/Podfile +++ b/example/IonicCapOneSignal/ios/App/Podfile @@ -30,3 +30,7 @@ end target 'OneSignalNotificationServiceExtension' do pod 'OneSignalXCFramework', '>= 5.0', '< 6.0' end + +target 'ExampleWidgetExtension' do + pod 'OneSignalXCFramework', '>= 5.0', '< 6.0' +end \ No newline at end of file diff --git a/example/IonicCapOneSignal/ios/App/Podfile.lock b/example/IonicCapOneSignal/ios/App/Podfile.lock index f27a2d64..86a8679a 100644 --- a/example/IonicCapOneSignal/ios/App/Podfile.lock +++ b/example/IonicCapOneSignal/ios/App/Podfile.lock @@ -12,44 +12,49 @@ PODS: - Capacitor - CordovaPluginsStatic (6.0.0): - CapacitorCordova - - OneSignalXCFramework (= 5.1.6) - - OneSignalXCFramework (5.1.6): - - OneSignalXCFramework/OneSignalComplete (= 5.1.6) - - OneSignalXCFramework/OneSignal (5.1.6): + - OneSignalXCFramework (= 5.2.0) + - OneSignalXCFramework (5.2.0): + - OneSignalXCFramework/OneSignalComplete (= 5.2.0) + - OneSignalXCFramework/OneSignal (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalExtension + - OneSignalXCFramework/OneSignalLiveActivities - OneSignalXCFramework/OneSignalNotifications - OneSignalXCFramework/OneSignalOSCore - OneSignalXCFramework/OneSignalOutcomes - OneSignalXCFramework/OneSignalUser - - OneSignalXCFramework/OneSignalComplete (5.1.6): + - OneSignalXCFramework/OneSignalComplete (5.2.0): - OneSignalXCFramework/OneSignal - OneSignalXCFramework/OneSignalInAppMessages - OneSignalXCFramework/OneSignalLocation - - OneSignalXCFramework/OneSignalCore (5.1.6) - - OneSignalXCFramework/OneSignalExtension (5.1.6): + - OneSignalXCFramework/OneSignalCore (5.2.0) + - OneSignalXCFramework/OneSignalExtension (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalOutcomes - - OneSignalXCFramework/OneSignalInAppMessages (5.1.6): + - OneSignalXCFramework/OneSignalInAppMessages (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalNotifications - OneSignalXCFramework/OneSignalOSCore - OneSignalXCFramework/OneSignalOutcomes - OneSignalXCFramework/OneSignalUser - - OneSignalXCFramework/OneSignalLocation (5.1.6): + - OneSignalXCFramework/OneSignalLiveActivities (5.2.0): + - OneSignalXCFramework/OneSignalCore + - OneSignalXCFramework/OneSignalOSCore + - OneSignalXCFramework/OneSignalUser + - OneSignalXCFramework/OneSignalLocation (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalNotifications - OneSignalXCFramework/OneSignalOSCore - OneSignalXCFramework/OneSignalUser - - OneSignalXCFramework/OneSignalNotifications (5.1.6): + - OneSignalXCFramework/OneSignalNotifications (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalExtension - OneSignalXCFramework/OneSignalOutcomes - - OneSignalXCFramework/OneSignalOSCore (5.1.6): + - OneSignalXCFramework/OneSignalOSCore (5.2.0): - OneSignalXCFramework/OneSignalCore - - OneSignalXCFramework/OneSignalOutcomes (5.1.6): + - OneSignalXCFramework/OneSignalOutcomes (5.2.0): - OneSignalXCFramework/OneSignalCore - - OneSignalXCFramework/OneSignalUser (5.1.6): + - OneSignalXCFramework/OneSignalUser (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalNotifications - OneSignalXCFramework/OneSignalOSCore @@ -92,9 +97,9 @@ SPEC CHECKSUMS: CapacitorHaptics: 9ebc9363f0e9b8eb4295088a0b474530acf1859b CapacitorKeyboard: deacbd09d8d1029c3681197fb05d206b721d5f73 CapacitorStatusBar: 2e4369f99166125435641b1908d05f561eaba6f6 - CordovaPluginsStatic: 0c92d460153b745e1dfbe367288a104177b55e46 - OneSignalXCFramework: f6533cc1f7a5ddded80ee5fe183901a99ad46f4f + CordovaPluginsStatic: 3355cb91038bf10f85a071f96c435dcabc8cc8ae + OneSignalXCFramework: bdf74fdc06888f9466dc21e826fe1549ed143095 -PODFILE CHECKSUM: c53c4ae8125a20193a7e94262437a687b59eaebb +PODFILE CHECKSUM: 178e2a2e451311a871c2b4db713ac4b63d0ebeeb COCOAPODS: 1.15.2 diff --git a/example/IonicCapOneSignal/package-lock.json b/example/IonicCapOneSignal/package-lock.json index c297a8f6..c55a27fe 100644 --- a/example/IonicCapOneSignal/package-lock.json +++ b/example/IonicCapOneSignal/package-lock.json @@ -48,7 +48,7 @@ }, "../..": { "name": "onesignal-cordova-plugin", - "version": "5.1.3", + "version": "5.1.4", "engines": [ { "name": "cordova-android", diff --git a/example/IonicCapOneSignal/src/OSButtons.tsx b/example/IonicCapOneSignal/src/OSButtons.tsx index df0ebf7f..fc0d66a0 100644 --- a/example/IonicCapOneSignal/src/OSButtons.tsx +++ b/example/IonicCapOneSignal/src/OSButtons.tsx @@ -428,6 +428,72 @@ class OSButtons extends React.Component { ]; } + createLiveActivitiesFields() { + const { loggingFunction } = this.props; + + const startDefaultLiveActivityButton = renderButtonView( + 'Start Default', + async () => { + const activityId = this.props.inputFieldValue; + loggingFunction('Start Default Live Activity: ', activityId); + await OneSignal.LiveActivities.startDefault( + activityId, + { title: 'Welcome!' }, + { + message: {en: 'Hello World!'}, + intValue: 3, + doubleValue: 3.14, + boolValue: true, + }, + ); + }, + ); + + const getEnterLiveActivityButton = renderButtonView( + 'Enter Live Activity', + async () => { + const activityId = this.props.inputFieldValue; + loggingFunction('Enter Live Activity: ', activityId); + await OneSignal.LiveActivities.enter(activityId, "FAKE_TOKEN"); + }, + ); + + const getExitLiveActivityButton = renderButtonView( + 'Exit Live Activity', + async () => { + const activityId = this.props.inputFieldValue; + loggingFunction('Exit Live Activity: ', activityId); + await OneSignal.LiveActivities.exit(activityId); + } + ); + + const getSetupPushToStartButton = renderButtonView( + 'Setup Push To Start', + () => { + const activityType = this.props.inputFieldValue; + loggingFunction('Setting up push to start: ', activityType); + OneSignal.LiveActivities.setPushToStartToken(activityType, "FAKE_TOKEN"); + } + ); + + const getRemovePushToStartButton = renderButtonView( + 'Remove Push To Start', + () => { + const activityType = this.props.inputFieldValue; + loggingFunction('Remove push to start: ', activityType); + OneSignal.LiveActivities.removePushToStartToken(activityType); + } + ); + + return [ + startDefaultLiveActivityButton, + getEnterLiveActivityButton, + getExitLiveActivityButton, + getSetupPushToStartButton, + getRemovePushToStartButton, + ]; + } + createPrivacyConsentFields() { const { loggingFunction } = this.props; @@ -486,6 +552,8 @@ class OSButtons extends React.Component {
{this.createUserFields()}
Push Subscription
{this.createPushSubscriptionFields()}
+
Live Activities
+
{this.createLiveActivitiesFields()}
Privacy Consent
{this.createPrivacyConsentFields()}
diff --git a/example/IonicCapOneSignal/src/OSDemo.tsx b/example/IonicCapOneSignal/src/OSDemo.tsx index 27f35ac2..856bd1fa 100644 --- a/example/IonicCapOneSignal/src/OSDemo.tsx +++ b/example/IonicCapOneSignal/src/OSDemo.tsx @@ -35,8 +35,9 @@ class OSDemo extends React.Component { } async componentDidMount() { - OneSignal.initialize(APP_ID); OneSignal.Debug.setLogLevel(LogLevel.Verbose); + OneSignal.initialize(APP_ID); + OneSignal.LiveActivities.setupDefault(); OneSignal.Notifications.addEventListener( 'foregroundWillDisplay', diff --git a/src/android/com/onesignal/cordova/OneSignalController.java b/src/android/com/onesignal/cordova/OneSignalController.java index 62e98197..1abaad43 100644 --- a/src/android/com/onesignal/cordova/OneSignalController.java +++ b/src/android/com/onesignal/cordova/OneSignalController.java @@ -325,4 +325,24 @@ public static boolean exitLiveActivity() { // doesn't apply to Android return true; } + + public static boolean setPushToStartToken() { + // doesn't apply to Android + return true; + } + + public static boolean removePushToStartToken() { + // doesn't apply to Android + return true; + } + + public static boolean setupDefaultLiveActivity() { + // doesn't apply to Android + return true; + } + + public static boolean startDefaultLiveActivity() { + // doesn't apply to Android + return true; + } } diff --git a/src/android/com/onesignal/cordova/OneSignalPush.java b/src/android/com/onesignal/cordova/OneSignalPush.java index 533aa845..aaa426dd 100644 --- a/src/android/com/onesignal/cordova/OneSignalPush.java +++ b/src/android/com/onesignal/cordova/OneSignalPush.java @@ -138,6 +138,10 @@ public class OneSignalPush extends CordovaPlugin implements INotificationLifecyc private static final String ENTER_LIVE_ACTIVITY = "enterLiveActivity"; private static final String EXIT_LIVE_ACTIVITY = "exitLiveActivity"; + private static final String SET_PUSH_TO_START_TOKEN = "setPushToStartToken"; + private static final String REMOVE_PUSH_TO_START_TOKEN = "removePushToStartToken"; + private static final String SETUP_DEFAULT_ACTIVITY = "setupDefaultLiveActivity"; + private static final String START_DEFAULT_LIVE_ACTIVITY = "startDefaultLiveActivity"; private static final HashMap notificationWillDisplayCache = new HashMap<>(); private static final HashMap preventDefaultCache = new HashMap<>(); @@ -604,6 +608,22 @@ public boolean execute(String action, JSONArray data, CallbackContext callbackCo result = OneSignalController.exitLiveActivity(); break; + case SET_PUSH_TO_START_TOKEN: + result = OneSignalController.setPushToStartToken(); + break; + + case REMOVE_PUSH_TO_START_TOKEN: + result = OneSignalController.removePushToStartToken(); + break; + + case SETUP_DEFAULT_ACTIVITY: + result = OneSignalController.setupDefaultLiveActivity(); + break; + + case START_DEFAULT_LIVE_ACTIVITY: + result = OneSignalController.startDefaultLiveActivity(); + break; + default: Logging.error(TAG + "Invalid action : " + action, null); CallbackHelper.callbackError(callbackContext, "Invalid action : " + action); diff --git a/src/ios/OneSignalPush.h b/src/ios/OneSignalPush.h index 7782cb2e..a2d0321b 100644 --- a/src/ios/OneSignalPush.h +++ b/src/ios/OneSignalPush.h @@ -121,5 +121,9 @@ // Live Activity - (void)enterLiveActivity:(CDVInvokedUrlCommand* _Nonnull)command; - (void)exitLiveActivity:(CDVInvokedUrlCommand* _Nonnull)command; +- (void)setPushToStartToken:(CDVInvokedUrlCommand* _Nonnull)command; +- (void)removePushToStartToken:(CDVInvokedUrlCommand* _Nonnull)command; +- (void)setupDefaultLiveActivity:(CDVInvokedUrlCommand* _Nonnull)command; +- (void)startDefaultLiveActivity:(CDVInvokedUrlCommand* _Nonnull)command; @end diff --git a/src/ios/OneSignalPush.m b/src/ios/OneSignalPush.m index 46859c11..7ec8408d 100644 --- a/src/ios/OneSignalPush.m +++ b/src/ios/OneSignalPush.m @@ -30,6 +30,7 @@ #import "OneSignalPush.h" #import +#import "OneSignalLiveActivities/OneSignalLiveActivities-Swift.h" NSString* notificationWillShowInForegoundCallbackId; NSString* notificationClickedCallbackId; @@ -634,4 +635,61 @@ - (void)exitLiveActivity:(CDVInvokedUrlCommand *)command { }]; } +- (void)setPushToStartToken:(CDVInvokedUrlCommand *)command { + NSString *activityType = command.arguments[0]; + NSString *token = command.arguments[1]; + NSError* err=nil; + + if (@available(iOS 17.2, *)) { + [OneSignalLiveActivitiesManagerImpl setPushToStartToken:activityType withToken:token error:&err]; + if (err) { + [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"activityType must be the name of your ActivityAttributes struct"]]; + } + } else { + [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setPushToStartToken on iOS < 17.2"]]; + } +} + +- (void)removePushToStartToken:(CDVInvokedUrlCommand *)command { + NSString *activityType = command.arguments[0]; + NSError* err=nil; + + if (@available(iOS 17.2, *)) { + [OneSignalLiveActivitiesManagerImpl removePushToStartToken:activityType error:&err]; + if (err) { + [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"activityType must be the name of your ActivityAttributes struct"]]; + } + } else { + [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot removePushToStartToken on iOS < 17.2"]]; + } +} + +- (void)setupDefaultLiveActivity:(CDVInvokedUrlCommand *)command { + NSDictionary *options = command.arguments[0]; + LiveActivitySetupOptions *laOptions = nil; + + if (options != [NSNull null]) { + laOptions = [LiveActivitySetupOptions alloc]; + [laOptions setEnablePushToStart:[options[@"enablePushToStart"] boolValue]]; + [laOptions setEnablePushToUpdate:[options[@"enablePushToUpdate"] boolValue]]; + } + + if (@available(iOS 16.1, *)) { + [OneSignalLiveActivitiesManagerImpl setupDefaultWithOptions:laOptions]; + } else { + [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setupDefault on iOS < 16.1"]]; + } +} + +- (void)startDefaultLiveActivity:(CDVInvokedUrlCommand *)command { + NSString *activityId = command.arguments[0]; + NSDictionary *attributes = command.arguments[1]; + NSDictionary *content = command.arguments[2]; + + if (@available(iOS 16.1, *)) { + [OneSignalLiveActivitiesManagerImpl startDefault:activityId attributes:attributes content:content]; + } else { + [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot startDefault on iOS < 16.1"]]; + } +} @end diff --git a/www/LiveActivitiesNamespace.ts b/www/LiveActivitiesNamespace.ts index 64fbfe59..8c82e6ee 100644 --- a/www/LiveActivitiesNamespace.ts +++ b/www/LiveActivitiesNamespace.ts @@ -1,3 +1,5 @@ +import { LiveActivitySetupOptions } from "./models/LiveActivities"; + // Suppress TS warnings about window.cordova declare let window: any; // turn off type checking @@ -40,4 +42,68 @@ export default class LiveActivities { window.cordova.exec(onSuccess, onFailure, "OneSignalPush", "exitLiveActivity", [activityId]); }; + + + /** + * Indicate this device is capable of receiving pushToStart live activities for the + * `activityType`. The `activityType` **must** be the name of the struct conforming + * to `ActivityAttributes` that will be used to start the live activity. + * + * Only applies to iOS + * + * @param {string} activityType: The name of the specific `ActivityAttributes` structure tied + * to the live activity. + * @param {string} token: The activity type's pushToStart token. + */ + setPushToStartToken(activityType: string, token: string) { + window.cordova.exec(function(){}, function(){}, "OneSignalPush", "setPushToStartToken", [activityType, token]); + } + + /** + * Indicate this device is no longer capable of receiving pushToStart live activities + * for the `activityType`. The `activityType` **must** be the name of the struct conforming + * to `ActivityAttributes` that will be used to start the live activity. + * + * Only applies to iOS + * + * @param {string} activityType: The name of the specific `ActivityAttributes` structure tied + * to the live activity. + */ + removePushToStartToken(activityType: string) { + window.cordova.exec(function(){}, function(){}, "OneSignalPush", "removePushToStartToken", [activityType]); + } + + /** + * Enable the OneSignalSDK to setup the default`DefaultLiveActivityAttributes` structure, + * which conforms to the `OneSignalLiveActivityAttributes`. When using this function, the + * widget attributes are owned by the OneSignal SDK, which will allow the SDK to handle the + * entire lifecycle of the live activity. All that is needed from an app-perspective is to + * create a Live Activity widget in a widget extension, with a `ActivityConfiguration` for + * `DefaultLiveActivityAttributes`. This is most useful for users that (1) only have one Live + * Activity widget and (2) are using a cross-platform framework and do not want to create the + * cross-platform <-> iOS native bindings to manage ActivityKit. + * + * Only applies to iOS + * + * @param {LiveActivitySetupOptions} options: An optional structure to provide for more granular setup options. + */ + setupDefault(options?: LiveActivitySetupOptions) { + window.cordova.exec(function(){}, function(){}, "OneSignalPush", "setupDefaultLiveActivity", [options]); + } + + /** + * Start a new LiveActivity that is modelled by the default`DefaultLiveActivityAttributes` + * structure. The `DefaultLiveActivityAttributes` is initialized with the dynamic `attributes` + * and `content` passed in. + * + * Only applies to iOS + * + * @param {string} activityId: The activity identifier the live activity on this device will be started + * and eligible to receive updates for. + * @param {object} attributes: A dynamic type containing the static attributes passed into `DefaultLiveActivityAttributes`. + * @param {object} content: A dynamic type containing the content attributes passed into `DefaultLiveActivityAttributes`. + */ + startDefault(activityId: string, attributes: object, content: object,) { + window.cordova.exec(function(){}, function(){}, "OneSignalPush", "startDefaultLiveActivity", [activityId, attributes, content]); + } } diff --git a/www/models/LiveActivities.ts b/www/models/LiveActivities.ts new file mode 100644 index 00000000..e88ab987 --- /dev/null +++ b/www/models/LiveActivities.ts @@ -0,0 +1,15 @@ +/** + * The setup options for `OneSignal.LiveActivities.setupDefault`. + */ +export type LiveActivitySetupOptions = { + /** + * When true, OneSignal will listen for pushToStart tokens for the `OneSignalLiveActivityAttributes` structure. + */ + enablePushToStart: boolean; + + /** + * When true, OneSignal will listen for pushToUpdate tokens for each start live activity that uses the + * `OneSignalLiveActivityAttributes` structure. + */ + enablePushToUpdate: boolean; +}