diff --git a/example/ios/ExampleWidget/Assets.xcassets/AccentColor.colorset/Contents.json b/example/ios/ExampleWidget/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/example/ios/ExampleWidget/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/example/ios/ExampleWidget/Assets.xcassets/AppIcon.appiconset/Contents.json b/example/ios/ExampleWidget/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..13613e3e --- /dev/null +++ b/example/ios/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/ios/ExampleWidget/Assets.xcassets/Contents.json b/example/ios/ExampleWidget/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/example/ios/ExampleWidget/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/example/ios/ExampleWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json b/example/ios/ExampleWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/example/ios/ExampleWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/example/ios/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/Contents.json b/example/ios/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/Contents.json new file mode 100644 index 00000000..0eddeb7c --- /dev/null +++ b/example/ios/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/ios/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/onesignal-logo.png b/example/ios/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/onesignal-logo.png new file mode 100644 index 00000000..ba97c7a7 Binary files /dev/null and b/example/ios/ExampleWidget/Assets.xcassets/onesignaldemo.imageset/onesignal-logo.png differ diff --git a/example/ios/ExampleWidget/ExampleWidgetBundle.swift b/example/ios/ExampleWidget/ExampleWidgetBundle.swift new file mode 100644 index 00000000..71407d0a --- /dev/null +++ b/example/ios/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/ios/ExampleWidget/ExampleWidgetLiveActivity.swift b/example/ios/ExampleWidget/ExampleWidgetLiveActivity.swift new file mode 100644 index 00000000..f372e2ef --- /dev/null +++ b/example/ios/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("FLUTTER: " + (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/ios/ExampleWidget/Info.plist b/example/ios/ExampleWidget/Info.plist new file mode 100644 index 00000000..0f118fb7 --- /dev/null +++ b/example/ios/ExampleWidget/Info.plist @@ -0,0 +1,11 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105..7c569640 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/example/ios/Flutter/Flutter.podspec b/example/ios/Flutter/Flutter.podspec index 8ce43943..98e16339 100644 --- a/example/ios/Flutter/Flutter.podspec +++ b/example/ios/Flutter/Flutter.podspec @@ -1,6 +1,6 @@ # -# NOTE: This podspec is NOT to be published. It is only used as a local source! -# This is a generated file; do not edit or check into version control. +# This podspec is NOT to be published. It is only used as a local source! +# This is a generated file; do not edit or check into version control. # Pod::Spec.new do |s| @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.license = { :type => 'BSD' } s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } - s.ios.deployment_target = '11.0' + s.ios.deployment_target = '12.0' # Framework linking is handled by Flutter tooling, not CocoaPods. # Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs. s.vendored_frameworks = 'path/to/nothing' diff --git a/example/ios/Podfile b/example/ios/Podfile index 92a74ef8..33fe22f4 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '11.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -35,6 +35,10 @@ target 'OneSignalNotificationServiceExtension' do pod 'OneSignalXCFramework', '>= 5.0.2', '< 6.0.0' end +target 'ExampleWidgetExtension' do + pod 'OneSignalXCFramework', '>= 5.0.2', '< 6.0.0' +end + post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index e658dae3..6f5efb0f 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,45 +1,50 @@ PODS: - Flutter (1.0.0) - - onesignal_flutter (5.0.0): + - onesignal_flutter (5.1.5): - Flutter - - OneSignalXCFramework (= 5.0.1) - - OneSignalXCFramework (5.0.1): - - OneSignalXCFramework/OneSignalComplete (= 5.0.1) - - OneSignalXCFramework/OneSignal (5.0.1): + - 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.0.1): + - OneSignalXCFramework/OneSignalComplete (5.2.0): - OneSignalXCFramework/OneSignal - OneSignalXCFramework/OneSignalInAppMessages - OneSignalXCFramework/OneSignalLocation - - OneSignalXCFramework/OneSignalCore (5.0.1) - - OneSignalXCFramework/OneSignalExtension (5.0.1): + - OneSignalXCFramework/OneSignalCore (5.2.0) + - OneSignalXCFramework/OneSignalExtension (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalOutcomes - - OneSignalXCFramework/OneSignalInAppMessages (5.0.1): + - OneSignalXCFramework/OneSignalInAppMessages (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalNotifications - OneSignalXCFramework/OneSignalOSCore - OneSignalXCFramework/OneSignalOutcomes - OneSignalXCFramework/OneSignalUser - - OneSignalXCFramework/OneSignalLocation (5.0.1): + - 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.0.1): + - OneSignalXCFramework/OneSignalNotifications (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalExtension - OneSignalXCFramework/OneSignalOutcomes - - OneSignalXCFramework/OneSignalOSCore (5.0.1): + - OneSignalXCFramework/OneSignalOSCore (5.2.0): - OneSignalXCFramework/OneSignalCore - - OneSignalXCFramework/OneSignalOutcomes (5.0.1): + - OneSignalXCFramework/OneSignalOutcomes (5.2.0): - OneSignalXCFramework/OneSignalCore - - OneSignalXCFramework/OneSignalUser (5.0.1): + - OneSignalXCFramework/OneSignalUser (5.2.0): - OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalNotifications - OneSignalXCFramework/OneSignalOSCore @@ -48,7 +53,7 @@ PODS: DEPENDENCIES: - Flutter (from `Flutter`) - onesignal_flutter (from `.symlinks/plugins/onesignal_flutter/ios`) - - OneSignalXCFramework (< 6.0.0, >= 5.0.1) + - OneSignalXCFramework (< 6.0.0, >= 5.0.2) SPEC REPOS: trunk: @@ -61,10 +66,10 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/onesignal_flutter/ios" SPEC CHECKSUMS: - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - onesignal_flutter: 33912d40612d20a6b34cd77e3d783f61843493fc - OneSignalXCFramework: 8429bc2456554da1b09b17135621087152ad05a0 + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + onesignal_flutter: 6e7b22bc9bbdb32cbaf79728e624a02264adec94 + OneSignalXCFramework: bdf74fdc06888f9466dc21e826fe1549ed143095 -PODFILE CHECKSUM: 90d5364fb6d80b7d4d98fb125af13a6b8da34c0b +PODFILE CHECKSUM: 4866dde54f21b323e83902730ef350ff4a561f44 -COCOAPODS: 1.12.1 +COCOAPODS: 1.15.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 562d06cd..5c4161de 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -7,9 +7,16 @@ objects = { /* Begin PBXBuildFile section */ + 039D7DFFEE45276B942FFE74 /* libPods-ExampleWidgetExtension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D2D44FBAFF27C19CAC1AE79 /* libPods-ExampleWidgetExtension.a */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3370773A86F73EB1712145D3 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B51BEA71462CEE42B0AC637B /* libPods-Runner.a */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 47CD9D252BE10D9400F8B006 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 47CD9D242BE10D9400F8B006 /* WidgetKit.framework */; }; + 47CD9D272BE10D9400F8B006 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 47CD9D262BE10D9400F8B006 /* SwiftUI.framework */; }; + 47CD9D2A2BE10D9400F8B006 /* ExampleWidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47CD9D292BE10D9400F8B006 /* ExampleWidgetBundle.swift */; }; + 47CD9D2C2BE10D9400F8B006 /* ExampleWidgetLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47CD9D2B2BE10D9400F8B006 /* ExampleWidgetLiveActivity.swift */; }; + 47CD9D302BE10D9500F8B006 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 47CD9D2F2BE10D9500F8B006 /* Assets.xcassets */; }; + 47CD9D342BE10D9500F8B006 /* ExampleWidgetExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 47CD9D232BE10D9400F8B006 /* ExampleWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; @@ -26,6 +33,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 47CD9D322BE10D9500F8B006 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 47CD9D222BE10D9400F8B006; + remoteInfo = ExampleWidgetExtension; + }; CAB34E9E20F96F460024CA6B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 97C146E61CF9000F007C117D /* Project object */; @@ -53,6 +67,7 @@ dstSubfolderSpec = 13; files = ( CAB34E9D20F96F460024CA6B /* OneSignalNotificationServiceExtension.appex in Embed App Extensions */, + 47CD9D342BE10D9500F8B006 /* ExampleWidgetExtension.appex in Embed App Extensions */, ); name = "Embed App Extensions"; runOnlyForDeploymentPostprocessing = 0; @@ -63,6 +78,14 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 3D2D44FBAFF27C19CAC1AE79 /* libPods-ExampleWidgetExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ExampleWidgetExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 47CD9D232BE10D9400F8B006 /* ExampleWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ExampleWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 47CD9D242BE10D9400F8B006 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; + 47CD9D262BE10D9400F8B006 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; + 47CD9D292BE10D9400F8B006 /* ExampleWidgetBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleWidgetBundle.swift; sourceTree = ""; }; + 47CD9D2B2BE10D9400F8B006 /* ExampleWidgetLiveActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleWidgetLiveActivity.swift; sourceTree = ""; }; + 47CD9D2F2BE10D9500F8B006 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 47CD9D312BE10D9500F8B006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47FF2D2152AD7B79C3388A8D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 6BBCCF44B691DF76AC7D7376 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -79,6 +102,7 @@ 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B51BEA71462CEE42B0AC637B /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; B6E82E5AE029B858173EAE1C /* Pods-OneSignalNotificationServiceExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.debug.xcconfig"; path = "Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.debug.xcconfig"; sourceTree = ""; }; + C5E2684165E64B3DC2662546 /* Pods-ExampleWidgetExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleWidgetExtension.release.xcconfig"; path = "Target Support Files/Pods-ExampleWidgetExtension/Pods-ExampleWidgetExtension.release.xcconfig"; sourceTree = ""; }; CA23C3A020F4095B00835044 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; CA2C87D921014E1800D5D35D /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; CA2C87DB21014E1C00D5D35D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; @@ -88,10 +112,21 @@ CAB34E9220F96BDA0024CA6B /* NotificationService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationService.m; sourceTree = ""; }; CAB34E9420F96BDA0024CA6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; CAB34E9C20F96BE60024CA6B /* OneSignalNotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OneSignalNotificationServiceExtension.entitlements; sourceTree = ""; }; + E1B700F64C9347FDDF86950E /* Pods-ExampleWidgetExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleWidgetExtension.debug.xcconfig"; path = "Target Support Files/Pods-ExampleWidgetExtension/Pods-ExampleWidgetExtension.debug.xcconfig"; sourceTree = ""; }; ED0C29CB77DA85C95D265337 /* Pods-OneSignalNotificationServiceExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.release.xcconfig"; path = "Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 47CD9D202BE10D9400F8B006 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 47CD9D272BE10D9400F8B006 /* SwiftUI.framework in Frameworks */, + 47CD9D252BE10D9400F8B006 /* WidgetKit.framework in Frameworks */, + 039D7DFFEE45276B942FFE74 /* libPods-ExampleWidgetExtension.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EB1CF9000F007C117D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -114,6 +149,17 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 47CD9D282BE10D9400F8B006 /* ExampleWidget */ = { + isa = PBXGroup; + children = ( + 47CD9D292BE10D9400F8B006 /* ExampleWidgetBundle.swift */, + 47CD9D2B2BE10D9400F8B006 /* ExampleWidgetLiveActivity.swift */, + 47CD9D2F2BE10D9500F8B006 /* Assets.xcassets */, + 47CD9D312BE10D9500F8B006 /* Info.plist */, + ); + path = ExampleWidget; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -131,6 +177,7 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, CAB34E9020F96BDA0024CA6B /* OneSignalNotificationServiceExtension */, + 47CD9D282BE10D9400F8B006 /* ExampleWidget */, 97C146EF1CF9000F007C117D /* Products */, E458450F0521E6D94C4900F1 /* Frameworks */, BA809C1A17A51DB9BC859D35 /* Pods */, @@ -142,6 +189,7 @@ children = ( 97C146EE1CF9000F007C117D /* Runner.app */, CAB34E8F20F96BDA0024CA6B /* OneSignalNotificationServiceExtension.appex */, + 47CD9D232BE10D9400F8B006 /* ExampleWidgetExtension.appex */, ); name = Products; sourceTree = ""; @@ -178,6 +226,8 @@ ED0C29CB77DA85C95D265337 /* Pods-OneSignalNotificationServiceExtension.release.xcconfig */, 6BBCCF44B691DF76AC7D7376 /* Pods-Runner.debug.xcconfig */, 47FF2D2152AD7B79C3388A8D /* Pods-Runner.release.xcconfig */, + E1B700F64C9347FDDF86950E /* Pods-ExampleWidgetExtension.debug.xcconfig */, + C5E2684165E64B3DC2662546 /* Pods-ExampleWidgetExtension.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -201,6 +251,9 @@ CA2C87D921014E1800D5D35D /* SystemConfiguration.framework */, 8E4D5B9266C7F07DB2DF5189 /* libPods-OneSignalNotificationServiceExtension.a */, B51BEA71462CEE42B0AC637B /* libPods-Runner.a */, + 47CD9D242BE10D9400F8B006 /* WidgetKit.framework */, + 47CD9D262BE10D9400F8B006 /* SwiftUI.framework */, + 3D2D44FBAFF27C19CAC1AE79 /* libPods-ExampleWidgetExtension.a */, ); name = Frameworks; sourceTree = ""; @@ -208,6 +261,24 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 47CD9D222BE10D9400F8B006 /* ExampleWidgetExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = 47CD9D352BE10D9500F8B006 /* Build configuration list for PBXNativeTarget "ExampleWidgetExtension" */; + buildPhases = ( + AAFA6FB39320C73BA94587BA /* [CP] Check Pods Manifest.lock */, + 47CD9D1F2BE10D9400F8B006 /* Sources */, + 47CD9D202BE10D9400F8B006 /* Frameworks */, + 47CD9D212BE10D9400F8B006 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ExampleWidgetExtension; + productName = ExampleWidgetExtension; + productReference = 47CD9D232BE10D9400F8B006 /* ExampleWidgetExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; 97C146ED1CF9000F007C117D /* Runner */ = { isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; @@ -217,15 +288,16 @@ 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, - 9705A1C41CF9048500538489 /* Embed Frameworks */, - 3B06AD1E1E4923F5004D2608 /* Thin Binary */, CAB34EA020F96F460024CA6B /* Embed App Extensions */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 5726744B564FC3637D8684A2 /* [CP] Embed Pods Frameworks */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( CAB34E9F20F96F460024CA6B /* PBXTargetDependency */, + 47CD9D332BE10D9500F8B006 /* PBXTargetDependency */, ); name = Runner; productName = Runner; @@ -256,9 +328,13 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastSwiftUpdateCheck = 1530; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { + 47CD9D222BE10D9400F8B006 = { + CreatedOnToolsVersion = 15.3; + }; 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; DevelopmentTeam = 99SW8E36CT; @@ -299,11 +375,20 @@ targets = ( 97C146ED1CF9000F007C117D /* Runner */, CAB34E8E20F96BDA0024CA6B /* OneSignalNotificationServiceExtension */, + 47CD9D222BE10D9400F8B006 /* ExampleWidgetExtension */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 47CD9D212BE10D9400F8B006 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 47CD9D302BE10D9500F8B006 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EC1CF9000F007C117D /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -334,6 +419,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -375,6 +461,7 @@ "${PODS_XCFRAMEWORKS_BUILD_DIR}/OneSignalXCFramework/OneSignalCore/OneSignalCore.framework/OneSignalCore", "${PODS_XCFRAMEWORKS_BUILD_DIR}/OneSignalXCFramework/OneSignalExtension/OneSignalExtension.framework/OneSignalExtension", "${PODS_XCFRAMEWORKS_BUILD_DIR}/OneSignalXCFramework/OneSignalInAppMessages/OneSignalInAppMessages.framework/OneSignalInAppMessages", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/OneSignalXCFramework/OneSignalLiveActivities/OneSignalLiveActivities.framework/OneSignalLiveActivities", "${PODS_XCFRAMEWORKS_BUILD_DIR}/OneSignalXCFramework/OneSignalLocation/OneSignalLocation.framework/OneSignalLocation", "${PODS_XCFRAMEWORKS_BUILD_DIR}/OneSignalXCFramework/OneSignalNotifications/OneSignalNotifications.framework/OneSignalNotifications", "${PODS_XCFRAMEWORKS_BUILD_DIR}/OneSignalXCFramework/OneSignalOSCore/OneSignalOSCore.framework/OneSignalOSCore", @@ -387,6 +474,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OneSignalCore.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OneSignalExtension.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OneSignalInAppMessages.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OneSignalLiveActivities.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OneSignalLocation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OneSignalNotifications.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OneSignalOSCore.framework", @@ -435,9 +523,40 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n"; }; + AAFA6FB39320C73BA94587BA /* [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; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 47CD9D1F2BE10D9400F8B006 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 47CD9D2A2BE10D9400F8B006 /* ExampleWidgetBundle.swift in Sources */, + 47CD9D2C2BE10D9400F8B006 /* ExampleWidgetLiveActivity.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EA1CF9000F007C117D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -459,6 +578,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 47CD9D332BE10D9500F8B006 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 47CD9D222BE10D9400F8B006 /* ExampleWidgetExtension */; + targetProxy = 47CD9D322BE10D9500F8B006 /* PBXContainerItemProxy */; + }; CAB34E9F20F96F460024CA6B /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = CAB34E8E20F96BDA0024CA6B /* OneSignalNotificationServiceExtension */; @@ -486,6 +610,96 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 47CD9D362BE10D9500F8B006 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E1B700F64C9347FDDF86950E /* 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_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + 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 = "Copyright © 2024 The Chromium Authors. All rights reserved."; + 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_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 47CD9D372BE10D9500F8B006 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C5E2684165E64B3DC2662546 /* 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_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + 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 = "Copyright © 2024 The Chromium Authors. All rights reserved."; + 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_COMPILATION_MODE = wholemodule; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -531,7 +745,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -578,7 +792,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -590,6 +804,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; @@ -619,6 +834,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; @@ -662,7 +878,7 @@ ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -695,7 +911,7 @@ ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -713,6 +929,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 47CD9D352BE10D9500F8B006 /* Build configuration list for PBXNativeTarget "ExampleWidgetExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 47CD9D362BE10D9500F8B006 /* Debug */, + 47CD9D372BE10D9500F8B006 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 50a8cfc9..cdef6845 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion en CFBundleDisplayName @@ -29,6 +31,10 @@ NSAllowsArbitraryLoads + NSSupportsLiveActivities + + UIApplicationSupportsIndirectInputEvents + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -48,9 +54,5 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - diff --git a/example/lib/main.dart b/example/lib/main.dart index 1016ad3d..dd51f862 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -17,6 +17,7 @@ class _MyAppState extends State { String? _smsNumber; String? _externalUserId; String? _language; + String? _liveActivityId; bool _enableConsentButton = false; // CHANGE THIS parameter to true if you want to test GDPR privacy consent @@ -38,7 +39,10 @@ class _MyAppState extends State { OneSignal.consentRequired(_requireConsent); // NOTE: Replace with your own app ID from https://www.onesignal.com - OneSignal.initialize("0ba9731b-33bd-43f4-8b59-61172e27447d"); + OneSignal.initialize("77e32082-ea27-42e3-a898-c72e141824ef"); + + OneSignal.LiveActivities.setupDefault(); + // OneSignal.LiveActivities.setupDefault(options: new LiveActivitySetupOptions(enablePushToStart: false, enablePushToUpdate: true)); // AndroidOnly stat only // OneSignal.Notifications.removeNotification(1); @@ -267,6 +271,44 @@ class _MyAppState extends State { OneSignal.User.pushSubscription.optOut(); } + void _handleStartDefaultLiveActivity() { + if (_liveActivityId == null) return; + print("Starting default live activity"); + OneSignal.LiveActivities.startDefault(_liveActivityId!, { + "title": "Welcome!" + }, { + "message": {"en": "Hello World!"}, + "intValue": 3, + "doubleValue": 3.14, + "boolValue": true + }); + } + + void _handleEnterLiveActivity() { + if (_liveActivityId == null) return; + print("Entering live activity"); + OneSignal.LiveActivities.enterLiveActivity(_liveActivityId!, "FAKE_TOKEN"); + } + + void _handleExitLiveActivity() { + if (_liveActivityId == null) return; + print("Exiting live activity"); + OneSignal.LiveActivities.exitLiveActivity(_liveActivityId!); + } + + void _handleSetPushToStartLiveActivity() { + if (_liveActivityId == null) return; + print("Setting Push-To-Start live activity"); + OneSignal.LiveActivities.setPushToStartToken( + _liveActivityId!, "FAKE_TOKEN"); + } + + void _handleRemovePushToStartLiveActivity() { + if (_liveActivityId == null) return; + print("Setting Push-To-Start live activity"); + OneSignal.LiveActivities.removePushToStartToken(_liveActivityId!); + } + @override Widget build(BuildContext context) { return new MaterialApp( @@ -434,6 +476,50 @@ class _MyAppState extends State { new OneSignalButton( "Opt Out", _handleOptOut, !_enableConsentButton) ]), + new TableRow(children: [ + new TextField( + textAlign: TextAlign.center, + decoration: InputDecoration( + hintText: "Live Activity ID", + labelStyle: TextStyle( + color: Color.fromARGB(255, 212, 86, 83), + )), + onChanged: (text) { + this.setState(() { + _liveActivityId = text == "" ? null : text; + }); + }, + ) + ]), + new TableRow(children: [ + Container( + height: 8.0, + ) + ]), + new TableRow(children: [ + new OneSignalButton("Start Default Live Activity", + _handleStartDefaultLiveActivity, !_enableConsentButton) + ]), + new TableRow(children: [ + new OneSignalButton("Enter Live Activity", + _handleEnterLiveActivity, !_enableConsentButton) + ]), + new TableRow(children: [ + new OneSignalButton("Exit Live Activity", + _handleExitLiveActivity, !_enableConsentButton) + ]), + new TableRow(children: [ + new OneSignalButton( + "Set Push-To-Start Live Activity", + _handleSetPushToStartLiveActivity, + !_enableConsentButton) + ]), + new TableRow(children: [ + new OneSignalButton( + "Remove Push-To-Start Live Activity", + _handleRemovePushToStartLiveActivity, + !_enableConsentButton) + ]), ], ), ), diff --git a/ios/Classes/OSFlutterLiveActivities.m b/ios/Classes/OSFlutterLiveActivities.m index bb91344a..b7c4a44d 100644 --- a/ios/Classes/OSFlutterLiveActivities.m +++ b/ios/Classes/OSFlutterLiveActivities.m @@ -27,6 +27,7 @@ #import "OSFlutterLiveActivities.h" #import +#import "OneSignalLiveActivities/OneSignalLiveActivities-Swift.h" #import "OSFlutterCategories.h" @implementation OSFlutterLiveActivities @@ -45,6 +46,14 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { [self enterLiveActivity:call withResult:result]; else if ([@"OneSignal#exitLiveActivity" isEqualToString:call.method]) [self exitLiveActivity:call withResult:result]; + else if ([@"OneSignal#setPushToStartToken" isEqualToString:call.method]) + [self setPushToStartToken:call withResult:result]; + else if ([@"OneSignal#removePushToStartToken" isEqualToString:call.method]) + [self removePushToStartToken:call withResult:result]; + else if ([@"OneSignal#setupDefault" isEqualToString:call.method]) + [self setupDefault:call withResult:result]; + else if ([@"OneSignal#startDefault" isEqualToString:call.method]) + [self startDefault:call withResult:result]; else result(FlutterMethodNotImplemented); } @@ -70,4 +79,71 @@ - (void)exitLiveActivity:(FlutterMethodCall *)call withResult:(FlutterResult)res }]; } -@end \ No newline at end of file +- (void)setPushToStartToken:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSString *activityType = call.arguments[@"activityType"]; + NSString *token = call.arguments[@"token"]; + 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"]]; + } + + result(nil); +} + +- (void)removePushToStartToken:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSString *activityType = call.arguments[@"activityType"]; + 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"]]; + } + + result(nil); +} + +- (void)setupDefault:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSDictionary *options = call.arguments[@"options"]; + + 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"]]; + } + + result(nil); +} + +- (void)startDefault:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSString *activityId = call.arguments[@"activityId"]; + NSDictionary *attributes = call.arguments[@"attributes"]; + NSDictionary *content = call.arguments[@"content"]; + + 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"]]; + } + + result(nil); +} + +@end diff --git a/ios/onesignal_flutter.podspec b/ios/onesignal_flutter.podspec index 26d2d471..53592ff2 100644 --- a/ios/onesignal_flutter.podspec +++ b/ios/onesignal_flutter.podspec @@ -13,7 +13,7 @@ Pod::Spec.new do |s| s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.dependency 'OneSignalXCFramework', '5.1.6' + s.dependency 'OneSignalXCFramework', '5.2.0' s.ios.deployment_target = '11.0' s.static_framework = true end diff --git a/lib/src/liveactivities.dart b/lib/src/liveactivities.dart index ccff659f..aaf0f65e 100644 --- a/lib/src/liveactivities.dart +++ b/lib/src/liveactivities.dart @@ -6,8 +6,10 @@ class OneSignalLiveActivities { // private channels used to bridge to ObjC/Java MethodChannel _channel = const MethodChannel('OneSignal#liveactivities'); - /// Only applies to iOS - /// Associates a temporary push token with an Activity ID on the OneSignal server. + /// Indicate this device has exited a live activity, identified within OneSignal by the [activityId]. The + /// [token] is the ActivityKit's update token that will be used to update the live activity. + /// + /// Only applies to iOS. Future enterLiveActivity(String activityId, String token) async { if (Platform.isIOS) { return await _channel.invokeMethod("OneSignal#enterLiveActivity", @@ -15,12 +17,104 @@ class OneSignalLiveActivities { } } - /// Only applies to iOS - /// Deletes activityId associated temporary push token on the OneSignal server. + /// Indicate this device has exited a live activity, identified within OneSignal by the [activityId]. + /// + /// Only applies to iOS. Future exitLiveActivity(String activityId) async { if (Platform.isIOS) { return await _channel.invokeMethod( "OneSignal#exitLiveActivity", {'activityId': activityId}); } } + + /// 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. An optional [options] + /// parameter can be provided for more granular setup options. + /// + /// Only applies to iOS. + Future setupDefault({LiveActivitySetupOptions? options}) async { + if (Platform.isIOS) { + dynamic optionsMap; + + if (options != null) { + optionsMap = { + 'enablePushToStart': options.enablePushToStart, + 'enablePushToUpdate': options.enablePushToUpdate, + }; + } + + return await _channel + .invokeMethod("OneSignal#setupDefault", {'options': optionsMap}); + } + } + + /// Start a new LiveActivity that is modelled by the default`DefaultLiveActivityAttributes` + /// structure. The `DefaultLiveActivityAttributes` is initialized with the dynamic [attributes] + /// and [content] passed in. The live activity started can be updated with the [activityId] + /// provided. + /// + /// Only applies to iOS. + Future startDefault( + String activityId, dynamic attributes, dynamic content) async { + if (Platform.isIOS) { + return await _channel.invokeMethod("OneSignal#startDefault", { + 'activityId': activityId, + 'attributes': attributes, + 'content': content + }); + } + } + + /// 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. The [token] + /// is ActivityKit's pushToStart token that will be used to start the live activity. + /// + /// Only applies to iOS. + Future setPushToStartToken(String activityType, String token) async { + if (Platform.isIOS) { + return await _channel.invokeMethod("OneSignal#setPushToStartToken", + {'activityType': activityType, 'token': 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. + Future removePushToStartToken(String activityType) async { + if (Platform.isIOS) { + return await _channel.invokeMethod( + "OneSignal#removePushToStartToken", {'activityType': activityType}); + } + } +} + +/// The setup options for [OneSignal.LiveActivities.setupDefault]. +class LiveActivitySetupOptions { + bool _enablePushToStart = true; + bool _enablePushToUpdate = true; + + LiveActivitySetupOptions( + {bool enablePushToStart = true, bool enablePushToUpdate = true}) { + this._enablePushToStart = enablePushToStart; + this._enablePushToUpdate = enablePushToUpdate; + } + + /// When true, OneSignal will listen for pushToStart tokens. + bool get enablePushToStart { + return this._enablePushToStart; + } + + /// When true, OneSignal will listen for pushToUpdate tokens for each started live activity. + bool get enablePushToUpdate { + return this._enablePushToUpdate; + } }