From 755b48010b5eeee7d084d4b8ffb051cf17c22cc7 Mon Sep 17 00:00:00 2001 From: Fadi George Date: Tue, 6 Jan 2026 16:21:17 -0800 Subject: [PATCH 1/8] add SPM support for iOS plugin --- .gitignore | 6 +- .pubignore | 11 + analysis_options.yaml | 3 + ios/Assets/.gitkeep | 0 ios/onesignal_flutter.podspec | 4 +- ios/onesignal_flutter/Package.swift | 28 +++ .../onesignal_flutter/OSFlutterCategories.m | 206 ++++++++++++++++ .../onesignal_flutter/OSFlutterDebug.m | 68 ++++++ .../OSFlutterInAppMessages.m | 144 ++++++++++++ .../OSFlutterLiveActivities.m | 189 +++++++++++++++ .../onesignal_flutter/OSFlutterLocation.m | 68 ++++++ .../OSFlutterNotifications.m | 221 ++++++++++++++++++ .../OSFlutterPushSubscription.m | 85 +++++++ .../onesignal_flutter/OSFlutterSession.m | 77 ++++++ .../Sources/onesignal_flutter/OSFlutterUser.m | 180 ++++++++++++++ .../onesignal_flutter/OneSignalPlugin.m | 128 ++++++++++ .../onesignal_flutter/OSFlutterCategories.h | 82 +++++++ .../onesignal_flutter/OSFlutterDebug.h | 35 +++ .../OSFlutterInAppMessages.h | 38 +++ .../OSFlutterLiveActivities.h | 35 +++ .../onesignal_flutter/OSFlutterLocation.h | 35 +++ .../OSFlutterNotifications.h | 41 ++++ .../OSFlutterPushSubscription.h | 38 +++ .../onesignal_flutter/OSFlutterSession.h | 35 +++ .../include/onesignal_flutter/OSFlutterUser.h | 35 +++ .../onesignal_flutter/OneSignalPlugin.h | 36 +++ 26 files changed, 1821 insertions(+), 7 deletions(-) delete mode 100644 ios/Assets/.gitkeep create mode 100644 ios/onesignal_flutter/Package.swift create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterCategories.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterDebug.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterInAppMessages.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterLiveActivities.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterLocation.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterNotifications.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterPushSubscription.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterSession.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterUser.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/OneSignalPlugin.m create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterCategories.h create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterDebug.h create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterInAppMessages.h create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterLiveActivities.h create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterLocation.h create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterNotifications.h create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterPushSubscription.h create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterSession.h create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterUser.h create mode 100644 ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OneSignalPlugin.h diff --git a/.gitignore b/.gitignore index f624417f..c8e3beb2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,8 +25,4 @@ dlcov.log .idea/ # Swift Package Manager -**/.build/ -**/.swiftpm/ -**/Package.resolved -**/.lock -**/workspace-state.json +!.gitkeep diff --git a/.pubignore b/.pubignore index ab647e07..3df4e872 100644 --- a/.pubignore +++ b/.pubignore @@ -31,3 +31,14 @@ dlcov.log pubspec.lock .flutter-plugins-dependencies flutter_export_environment.sh +analysis_options.yaml + +# Misc +CODEOWNERS +CONTRIBUTING.md +MIGRATION_GUIDE.md + +# Examples +example +example_pod +example_spm diff --git a/analysis_options.yaml b/analysis_options.yaml index f7375932..14714683 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,3 +1,6 @@ analyzer: exclude: - test/dlcov_references_test.dart + - example/** + - example_pod/** + - example_spm/** diff --git a/ios/Assets/.gitkeep b/ios/Assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/ios/onesignal_flutter.podspec b/ios/onesignal_flutter.podspec index 5949a71e..78233bc9 100644 --- a/ios/onesignal_flutter.podspec +++ b/ios/onesignal_flutter.podspec @@ -10,8 +10,8 @@ Pod::Spec.new do |s| s.license = { :file => '../LICENSE' } s.author = { 'Brad Hesse' => 'brad@onesignal.com', 'Josh Kasten' => 'josh@onesignal.com' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.public_header_files = 'Classes/**/*.h' + s.source_files = 'onesignal_flutter/Sources/onesignal_flutter/**/*.{h,m}' + s.public_header_files = 'onesignal_flutter/Sources/onesignal_flutter/include/**/*.h' s.dependency 'Flutter' s.dependency 'OneSignalXCFramework', '5.2.15' s.ios.deployment_target = '11.0' diff --git a/ios/onesignal_flutter/Package.swift b/ios/onesignal_flutter/Package.swift new file mode 100644 index 00000000..8234d3bf --- /dev/null +++ b/ios/onesignal_flutter/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "onesignal_flutter", + platforms: [ + .iOS("12.0") + ], + products: [ + .library(name: "onesignal-flutter", targets: ["onesignal_flutter"]) + ], + dependencies: [ + .package(url: "https://github.com/OneSignal/OneSignal-XCFramework", exact: "5.2.15") + ], + targets: [ + .target( + name: "onesignal_flutter", + dependencies: [ + .product(name: "OneSignalFramework", package: "OneSignal-XCFramework"), + .product(name: "OneSignalInAppMessages", package: "OneSignal-XCFramework"), + .product(name: "OneSignalLocation", package: "OneSignal-XCFramework") + ], + path: "Sources/onesignal_flutter" + ) + ] +) diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterCategories.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterCategories.m new file mode 100644 index 00000000..536e047e --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterCategories.m @@ -0,0 +1,206 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "./include/onesignal_flutter/OSFlutterCategories.h" + +/* + The OneSignal iOS SDK implements similar methods (`toDictionary`) + However we decided to implement custom `toJson` methods for several + of these objects to add more properties. + + TODO: Update the native iOS SDK to add these details + (ie. `templateId` is missing from OSNotificationPayload's `toDictionary` + method in the native SDK) and remove them from here. +*/ + +@implementation OSNotification (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"contentAvailable"] = @(self.contentAvailable); + json[@"mutableContent"] = @(self.mutableContent); + + if (self.rawPayload) { + NSError *jsonError; + NSData *data = + [NSJSONSerialization dataWithJSONObject:self.rawPayload + options:NSJSONWritingPrettyPrinted + error:&jsonError]; + + if (!jsonError) { + NSString *rawPayloadString = + [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + json[@"rawPayload"] = rawPayloadString; + } + } + + if (self.notificationId) + json[@"notificationId"] = self.notificationId; + if (self.templateName) + json[@"templateName"] = self.templateName; + if (self.templateId) + json[@"templateId"] = self.templateId; + if (self.badge) + json[@"badge"] = @(self.badge); + if (self.badgeIncrement) + json[@"badgeIncrement"] = @(self.badgeIncrement); + if (self.sound) + json[@"sound"] = self.sound; + if (self.title) + json[@"title"] = self.title; + if (self.subtitle) + json[@"subtitle"] = self.subtitle; + if (self.body) + json[@"body"] = self.body; + if (self.launchURL) + json[@"launchUrl"] = self.launchURL; + if (self.additionalData) + json[@"additionalData"] = self.additionalData; + if (self.attachments) + json[@"attachments"] = self.attachments; + if (self.actionButtons) + json[@"buttons"] = self.actionButtons; + if (self.category) + json[@"category"] = self.category; + + return json; +} +@end + +@implementation OSNotificationClickEvent (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"notification"] = self.notification.toJson; + json[@"result"] = self.result.toJson; + + return json; +} +@end + +@implementation OSNotificationClickResult (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"action_id"] = self.actionId; + json[@"url"] = self.url; + + return json; +} +@end + +@implementation OSNotificationWillDisplayEvent (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"notification"] = self.notification.toJson; + + return json; +} +@end + +@implementation OSInAppMessageWillDisplayEvent (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"message"] = self.message.toJson; + + return json; +} +@end + +@implementation OSInAppMessageDidDisplayEvent (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"message"] = self.message.toJson; + + return json; +} +@end + +@implementation OSInAppMessageWillDismissEvent (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"message"] = self.message.toJson; + + return json; +} +@end + +@implementation OSInAppMessageDidDismissEvent (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"message"] = self.message.toJson; + + return json; +} +@end + +@implementation OSInAppMessageClickEvent (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"message"] = self.message.toJson; + json[@"result"] = self.result.toJson; + + return json; +} +@end + +@implementation OSInAppMessageClickResult (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"action_id"] = self.actionId; + json[@"url"] = self.url; + json[@"closing_message"] = @(self.closingMessage); + + return json; +} +@end + +@implementation OSInAppMessage (Flutter) +- (NSDictionary *)toJson { + NSMutableDictionary *json = [NSMutableDictionary new]; + + json[@"message_id"] = self.messageId; + + return json; +} +@end + +@implementation NSError (Flutter) +- (FlutterError *)flutterError { + return [FlutterError + errorWithCode:[NSString stringWithFormat:@"%i", (int)self.code] + message:self.localizedDescription + details:nil]; +} +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterDebug.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterDebug.m new file mode 100644 index 00000000..28ac9b28 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterDebug.m @@ -0,0 +1,68 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "./include/onesignal_flutter/OSFlutterDebug.h" +#import "./include/onesignal_flutter/OSFlutterCategories.h" +#import + +@implementation OSFlutterDebug ++ (void)registerWithRegistrar:(NSObject *)registrar { + OSFlutterDebug *instance = [OSFlutterDebug new]; + + instance.channel = + [FlutterMethodChannel methodChannelWithName:@"OneSignal#debug" + binaryMessenger:[registrar messenger]]; + + [registrar addMethodCallDelegate:instance channel:instance.channel]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call + result:(FlutterResult)result { + if ([@"OneSignal#setLogLevel" isEqualToString:call.method]) + [self setLogLevel:call withResult:result]; + else if ([@"OneSignal#setAlertLevel" isEqualToString:call.method]) + [self setAlertLevel:call withResult:result]; + else + result(FlutterMethodNotImplemented); +} + +- (void)setLogLevel:(FlutterMethodCall *)call withResult:(FlutterResult)result { + ONE_S_LOG_LEVEL logLevel = + (ONE_S_LOG_LEVEL)[call.arguments[@"logLevel"] intValue]; + [OneSignal.Debug setLogLevel:logLevel]; + result(nil); +} + +- (void)setAlertLevel:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + ONE_S_LOG_LEVEL visualLogLevel = + (ONE_S_LOG_LEVEL)[call.arguments[@"visualLevel"] intValue]; + [OneSignal.Debug setAlertLevel:visualLogLevel]; + result(nil); +} + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterInAppMessages.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterInAppMessages.m new file mode 100644 index 00000000..cec9c4fa --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterInAppMessages.m @@ -0,0 +1,144 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "./include/onesignal_flutter/OSFlutterInAppMessages.h" +#import "./include/onesignal_flutter/OSFlutterCategories.h" +#import + +@implementation OSFlutterInAppMessages + ++ (instancetype)sharedInstance { + static OSFlutterInAppMessages *sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [OSFlutterInAppMessages new]; + }); + return sharedInstance; +} + ++ (void)registerWithRegistrar:(NSObject *)registrar { + + OSFlutterInAppMessages.sharedInstance.channel = + [FlutterMethodChannel methodChannelWithName:@"OneSignal#inappmessages" + binaryMessenger:[registrar messenger]]; + + [registrar + addMethodCallDelegate:OSFlutterInAppMessages.sharedInstance + channel:OSFlutterInAppMessages.sharedInstance.channel]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call + result:(FlutterResult)result { + if ([@"OneSignal#addTrigger" isEqualToString:call.method]) + [self addTriggers:call withResult:result]; + else if ([@"OneSignal#addTriggers" isEqualToString:call.method]) + [self addTriggers:call withResult:result]; + else if ([@"OneSignal#removeTrigger" isEqualToString:call.method]) + [self removeTrigger:call withResult:result]; + else if ([@"OneSignal#removeTriggers" isEqualToString:call.method]) + [self removeTriggers:call withResult:result]; + else if ([@"OneSignal#clearTriggers" isEqualToString:call.method]) + [self clearTriggers:call withResult:result]; + else if ([@"OneSignal#paused" isEqualToString:call.method]) + [self paused:call withResult:result]; + else if ([@"OneSignal#arePaused" isEqualToString:call.method]) + result(@([OneSignal.InAppMessages paused])); + else if ([@"OneSignal#lifecycleInit" isEqualToString:call.method]) + [self lifecycleInit:call withResult:result]; + else + result(FlutterMethodNotImplemented); +} + +- (void)addTriggers:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSDictionary *triggers = call.arguments; + [OneSignal.InAppMessages addTriggers:triggers]; + result(nil); +} + +- (void)removeTrigger:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSString *key = call.arguments; + [OneSignal.InAppMessages removeTrigger:key]; + result(nil); +} + +- (void)removeTriggers:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSArray *keys = call.arguments; + [OneSignal.InAppMessages removeTriggers:keys]; + result(nil); +} + +- (void)clearTriggers:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + [OneSignal.InAppMessages clearTriggers]; + result(nil); +} + +- (void)paused:(FlutterMethodCall *)call withResult:(FlutterResult)result { + BOOL pause = [call.arguments boolValue]; + [OneSignal.InAppMessages paused:pause]; + result(nil); +} + +- (void)lifecycleInit:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + [OneSignal.InAppMessages + addClickListener:OSFlutterInAppMessages.sharedInstance]; + [OneSignal.InAppMessages + addLifecycleListener:OSFlutterInAppMessages.sharedInstance]; +} + +#pragma mark In App Message Click + +- (void)onClickInAppMessage:(OSInAppMessageClickEvent *_Nonnull)event { + [self.channel invokeMethod:@"OneSignal#onClickInAppMessage" + arguments:event.toJson]; +} + +#pragma mark OSInAppMessageLifecycleListener +- (void)onWillDisplayInAppMessage:(OSInAppMessageWillDisplayEvent *)event { + [self.channel invokeMethod:@"OneSignal#onWillDisplayInAppMessage" + arguments:event.toJson]; +} + +- (void)onDidDisplayInAppMessage:(OSInAppMessageDidDisplayEvent *)event { + [self.channel invokeMethod:@"OneSignal#onDidDisplayInAppMessage" + arguments:event.toJson]; +} + +- (void)onWillDismissInAppMessage:(OSInAppMessageWillDismissEvent *)event { + [self.channel invokeMethod:@"OneSignal#onWillDismissInAppMessage" + arguments:event.toJson]; +} + +- (void)onDidDismissInAppMessage:(OSInAppMessageDidDismissEvent *)event { + [self.channel invokeMethod:@"OneSignal#onDidDismissInAppMessage" + arguments:event.toJson]; +} + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterLiveActivities.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterLiveActivities.m new file mode 100644 index 00000000..ed86e620 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterLiveActivities.m @@ -0,0 +1,189 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "./include/onesignal_flutter/OSFlutterLiveActivities.h" +#import "./include/onesignal_flutter/OSFlutterCategories.h" +#import "OneSignalLiveActivities/OneSignalLiveActivities-Swift.h" +#import + +@implementation OSFlutterLiveActivities ++ (void)registerWithRegistrar:(NSObject *)registrar { + OSFlutterLiveActivities *instance = [OSFlutterLiveActivities new]; + + instance.channel = + [FlutterMethodChannel methodChannelWithName:@"OneSignal#liveactivities" + binaryMessenger:[registrar messenger]]; + + [registrar addMethodCallDelegate:instance channel:instance.channel]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call + result:(FlutterResult)result { + if ([@"OneSignal#enterLiveActivity" isEqualToString:call.method]) + [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); +} + +- (void)enterLiveActivity:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSString *activityId = call.arguments[@"activityId"]; + NSString *token = call.arguments[@"token"]; + + [OneSignal.LiveActivities enter:activityId + withToken:token + withSuccess:^(NSDictionary *results) { + result(results); + } + withFailure:^(NSError *error) { + result(error.flutterError); + }]; +} + +- (void)exitLiveActivity:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSString *activityId = call.arguments[@"activityId"]; + + [OneSignal.LiveActivities exit:activityId + withSuccess:^(NSDictionary *results) { + result(results); + } + withFailure:^(NSError *error) { + result(error.flutterError); + }]; +} + +- (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/Sources/onesignal_flutter/OSFlutterLocation.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterLocation.m new file mode 100644 index 00000000..ca088772 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterLocation.m @@ -0,0 +1,68 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "./include/onesignal_flutter/OSFlutterLocation.h" +#import "./include/onesignal_flutter/OSFlutterCategories.h" +#import + +@implementation OSFlutterLocation ++ (void)registerWithRegistrar:(NSObject *)registrar { + OSFlutterLocation *instance = [OSFlutterLocation new]; + + instance.channel = + [FlutterMethodChannel methodChannelWithName:@"OneSignal#location" + binaryMessenger:[registrar messenger]]; + + [registrar addMethodCallDelegate:instance channel:instance.channel]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call + result:(FlutterResult)result { + if ([@"OneSignal#requestPermission" isEqualToString:call.method]) + [self requestPermission:call withResult:result]; + else if ([@"OneSignal#setShared" isEqualToString:call.method]) + [self setLocationShared:call withResult:result]; + else if ([@"OneSignal#isShared" isEqualToString:call.method]) + result(@([OneSignal.Location isShared])); + else + result(FlutterMethodNotImplemented); +} + +- (void)setLocationShared:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + BOOL locationShared = [call.arguments boolValue]; + [OneSignal.Location setShared:locationShared]; + result(nil); +} + +- (void)requestPermission:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + [OneSignal.Location requestPermission]; + result(nil); +} + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterNotifications.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterNotifications.m new file mode 100644 index 00000000..d6053bea --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterNotifications.m @@ -0,0 +1,221 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "./include/onesignal_flutter/OSFlutterNotifications.h" +#import "./include/onesignal_flutter/OSFlutterCategories.h" +#import +#import + +@implementation OSFlutterNotifications + ++ (instancetype)sharedInstance { + static OSFlutterNotifications *sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [OSFlutterNotifications new]; + sharedInstance.onWillDisplayEventCache = [NSMutableDictionary new]; + sharedInstance.preventedDefaultCache = [NSMutableDictionary new]; + }); + return sharedInstance; +} + ++ (void)registerWithRegistrar:(NSObject *)registrar { + + OSFlutterNotifications.sharedInstance.channel = + [FlutterMethodChannel methodChannelWithName:@"OneSignal#notifications" + binaryMessenger:[registrar messenger]]; + + [registrar + addMethodCallDelegate:OSFlutterNotifications.sharedInstance + channel:OSFlutterNotifications.sharedInstance.channel]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call + result:(FlutterResult)result { + if ([@"OneSignal#permission" isEqualToString:call.method]) + result(@([OneSignal.Notifications permission])); + else if ([@"OneSignal#permissionNative" isEqualToString:call.method]) + [self permissionNative:call withResult:result]; + else if ([@"OneSignal#canRequest" isEqualToString:call.method]) + result(@([OneSignal.Notifications canRequestPermission])); + else if ([@"OneSignal#clearAll" isEqualToString:call.method]) + [self clearAll:call withResult:result]; + else if ([@"OneSignal#requestPermission" isEqualToString:call.method]) + [self requestPermission:call withResult:result]; + else if ([@"OneSignal#registerForProvisionalAuthorization" + isEqualToString:call.method]) + [self registerForProvisionalAuthorization:call withResult:result]; + else if ([@"OneSignal#displayNotification" isEqualToString:call.method]) + [self displayNotification:call withResult:result]; + else if ([@"OneSignal#preventDefault" isEqualToString:call.method]) + [self preventDefault:call withResult:result]; + else if ([@"OneSignal#lifecycleInit" isEqualToString:call.method]) + [self lifecycleInit:call withResult:result]; + else if ([@"OneSignal#proceedWithWillDisplay" isEqualToString:call.method]) + [self proceedWithWillDisplay:call withResult:result]; + else if ([@"OneSignal#addNativeClickListener" isEqualToString:call.method]) + [self registerClickListener:call withResult:result]; + else + result(FlutterMethodNotImplemented); +} + +- (void)permissionNative:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + OSNotificationPermission permission = + [OneSignal.Notifications permissionNative]; + result(@((int)permission)); +} + +- (void)clearAll:(FlutterMethodCall *)call withResult:(FlutterResult)result { + [OneSignal.Notifications clearAll]; + result(nil); +} + +- (void)requestPermission:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + BOOL fallbackToSettings = [call.arguments[@"fallbackToSettings"] boolValue]; + + [OneSignal.Notifications + requestPermission:^(BOOL accepted) { + result(@(accepted)); + } + fallbackToSettings:fallbackToSettings]; +} + +- (void)registerForProvisionalAuthorization:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + [OneSignal.Notifications + registerForProvisionalAuthorization:^(BOOL accepted) { + result(@(accepted)); + }]; +} + +- (void)lifecycleInit:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + [OneSignal.Notifications addForegroundLifecycleListener:self]; + [OneSignal.Notifications addPermissionObserver:self]; + result(nil); +} + +- (void)registerClickListener:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + [OneSignal.Notifications addClickListener:self]; + result(nil); +} + +- (void)onNotificationPermissionDidChange:(BOOL)permission { + [self.channel invokeMethod:@"OneSignal#onNotificationPermissionDidChange" + arguments:@{@"permission" : @(permission)}]; +} + +#pragma mark Received in Notification Lifecycle Event + +- (void)onWillDisplayNotification:(OSNotificationWillDisplayEvent *)event { + self.onWillDisplayEventCache[event.notification.notificationId] = event; + /// Our bridge layer needs to preventDefault so that the Flutter listener has + /// time to preventDefault before the notification is displayed + [event preventDefault]; + [self.channel invokeMethod:@"OneSignal#onWillDisplayNotification" + arguments:event.toJson]; +} + +/// Our bridge layer needs to preventDefault so that the Flutter listener has +/// time to preventDefault before the notification is displayed This function is +/// called after all of the flutter listeners have responded to the willDisplay +/// event. If any of them have called preventDefault we will not call display(). +/// Otherwise we will display. +- (void)proceedWithWillDisplay:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSString *notificationId = call.arguments[@"notificationId"]; + OSNotificationWillDisplayEvent *event = + self.onWillDisplayEventCache[notificationId]; + if (!event) { + [OneSignalLog + onesignalLog:ONE_S_LL_ERROR + message:[NSString + stringWithFormat: + @"OneSignal (objc): could not find notification " + @"will display event for notification with id: %@", + notificationId]]; + return; + } + if (self.preventedDefaultCache[notificationId]) { + return; + } + [event.notification display]; + result(nil); +} + +- (void)preventDefault:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSString *notificationId = call.arguments[@"notificationId"]; + OSNotificationWillDisplayEvent *event = + self.onWillDisplayEventCache[notificationId]; + + if (!event) { + [OneSignalLog + onesignalLog:ONE_S_LL_ERROR + message:[NSString + stringWithFormat: + @"OneSignal (objc): could not find notification " + @"will display event for notification with id: %@", + notificationId]]; + return; + } + [event preventDefault]; + self.preventedDefaultCache[event.notification.notificationId] = event; + result(nil); +} + +- (void)displayNotification:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSString *notificationId = call.arguments[@"notificationId"]; + OSNotificationWillDisplayEvent *event = + self.onWillDisplayEventCache[notificationId]; + + if (!event) { + [OneSignalLog + onesignalLog:ONE_S_LL_ERROR + message:[NSString + stringWithFormat: + @"OneSignal (objc): could not find notification " + @"will display event for notification with id: %@", + notificationId]]; + return; + } + [event.notification display]; + result(nil); +} + +#pragma mark Notification Click + +- (void)onClickNotification:(OSNotificationClickEvent *_Nonnull)event { + [self.channel invokeMethod:@"OneSignal#onClickNotification" + arguments:event.toJson]; +} + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterPushSubscription.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterPushSubscription.m new file mode 100644 index 00000000..35432f46 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterPushSubscription.m @@ -0,0 +1,85 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "./include/onesignal_flutter/OSFlutterPushSubscription.h" +#import "./include/onesignal_flutter/OSFlutterCategories.h" +#import +#import + +@implementation OSFlutterPushSubscription + ++ (void)registerWithRegistrar:(NSObject *)registrar { + OSFlutterPushSubscription *instance = [OSFlutterPushSubscription new]; + + instance.channel = + [FlutterMethodChannel methodChannelWithName:@"OneSignal#pushsubscription" + binaryMessenger:[registrar messenger]]; + + [registrar addMethodCallDelegate:instance channel:instance.channel]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call + result:(FlutterResult)result { + if ([@"OneSignal#pushSubscriptionId" isEqualToString:call.method]) + result(OneSignal.User.pushSubscription.id); + else if ([@"OneSignal#pushSubscriptionToken" isEqualToString:call.method]) + result(OneSignal.User.pushSubscription.token); + else if ([@"OneSignal#pushSubscriptionOptedIn" isEqualToString:call.method]) + result(@(OneSignal.User.pushSubscription.optedIn)); + else if ([@"OneSignal#optIn" isEqualToString:call.method]) + [self optIn:call withResult:result]; + else if ([@"OneSignal#optOut" isEqualToString:call.method]) + [self optOut:call withResult:result]; + else if ([@"OneSignal#lifecycleInit" isEqualToString:call.method]) + [self lifecycleInit:call withResult:result]; + else + result(FlutterMethodNotImplemented); +} + +- (void)optIn:(FlutterMethodCall *)call withResult:(FlutterResult)result { + [OneSignal.User.pushSubscription optIn]; + result(nil); +} + +- (void)optOut:(FlutterMethodCall *)call withResult:(FlutterResult)result { + [OneSignal.User.pushSubscription optOut]; + result(nil); +} + +- (void)lifecycleInit:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + [OneSignal.User.pushSubscription addObserver:self]; + result(nil); +} + +- (void)onPushSubscriptionDidChangeWithState: + (OSPushSubscriptionChangedState *)state { + [self.channel invokeMethod:@"OneSignal#onPushSubscriptionChange" + arguments:state.jsonRepresentation]; +} + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterSession.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterSession.m new file mode 100644 index 00000000..524c17a4 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterSession.m @@ -0,0 +1,77 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "./include/onesignal_flutter/OSFlutterSession.h" +#import "./include/onesignal_flutter/OSFlutterCategories.h" +#import + +@implementation OSFlutterSession ++ (void)registerWithRegistrar:(NSObject *)registrar { + OSFlutterSession *instance = [OSFlutterSession new]; + + instance.channel = + [FlutterMethodChannel methodChannelWithName:@"OneSignal#session" + binaryMessenger:[registrar messenger]]; + + [registrar addMethodCallDelegate:instance channel:instance.channel]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call + result:(FlutterResult)result { + if ([@"OneSignal#addOutcome" isEqualToString:call.method]) { + [self addOutcome:call withResult:result]; + } else if ([@"OneSignal#addUniqueOutcome" isEqualToString:call.method]) { + [self addUniqueOutcome:call withResult:result]; + } else if ([@"OneSignal#addOutcomeWithValue" isEqualToString:call.method]) { + [self addOutcomeWithValue:call withResult:result]; + } else { + result(FlutterMethodNotImplemented); + } +} + +- (void)addOutcome:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSString *name = call.arguments; + [OneSignal.Session addOutcome:name]; + result(nil); +} + +- (void)addUniqueOutcome:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSString *name = call.arguments; + [OneSignal.Session addUniqueOutcome:name]; + result(nil); +} + +- (void)addOutcomeWithValue:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSString *name = call.arguments[@"outcome_name"]; + NSNumber *value = call.arguments[@"outcome_value"]; + [OneSignal.Session addOutcomeWithValue:name value:value]; + result(nil); +} + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterUser.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterUser.m new file mode 100644 index 00000000..c57564ff --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OSFlutterUser.m @@ -0,0 +1,180 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#import "./include/onesignal_flutter/OSFlutterUser.h" +#import "./include/onesignal_flutter/OSFlutterCategories.h" +#import "./include/onesignal_flutter/OSFlutterPushSubscription.h" +#import +#import + +@implementation OSFlutterUser ++ (void)registerWithRegistrar:(NSObject *)registrar { + OSFlutterUser *instance = [OSFlutterUser new]; + + instance.channel = + [FlutterMethodChannel methodChannelWithName:@"OneSignal#user" + binaryMessenger:[registrar messenger]]; + + [registrar addMethodCallDelegate:instance channel:instance.channel]; + [OSFlutterPushSubscription registerWithRegistrar:registrar]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call + result:(FlutterResult)result { + if ([@"OneSignal#setLanguage" isEqualToString:call.method]) + [self setLanguage:call withResult:result]; + else if ([@"OneSignal#getOnesignalId" isEqualToString:call.method]) + [self getOnesignalId:call withResult:result]; + else if ([@"OneSignal#getExternalId" isEqualToString:call.method]) + [self getExternalId:call withResult:result]; + else if ([@"OneSignal#addAliases" isEqualToString:call.method]) + [self addAliases:call withResult:result]; + else if ([@"OneSignal#removeAliases" isEqualToString:call.method]) + [self removeAliases:call withResult:result]; + else if ([@"OneSignal#addTags" isEqualToString:call.method]) + [self addTags:call withResult:result]; + else if ([@"OneSignal#removeTags" isEqualToString:call.method]) + [self removeTags:call withResult:result]; + else if ([@"OneSignal#getTags" isEqualToString:call.method]) + [self getTags:call withResult:result]; + else if ([@"OneSignal#addEmail" isEqualToString:call.method]) + [self addEmail:call withResult:result]; + else if ([@"OneSignal#removeEmail" isEqualToString:call.method]) + [self removeEmail:call withResult:result]; + else if ([@"OneSignal#addSms" isEqualToString:call.method]) + [self addSms:call withResult:result]; + else if ([@"OneSignal#removeSms" isEqualToString:call.method]) + [self removeSms:call withResult:result]; + else if ([@"OneSignal#lifecycleInit" isEqualToString:call.method]) + [self lifecycleInit:call withResult:result]; + else + result(FlutterMethodNotImplemented); +} + +- (void)setLanguage:(FlutterMethodCall *)call withResult:(FlutterResult)result { + id language = call.arguments[@"language"]; + if (language == [NSNull null]) { + language = nil; + } + + [OneSignal.User setLanguage:language]; + result(nil); +} + +- (void)addAliases:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSDictionary *aliases = call.arguments; + [OneSignal.User addAliases:aliases]; + result(nil); +} + +- (void)removeAliases:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + NSDictionary *aliases = call.arguments; + [OneSignal.User removeAliases:aliases]; + result(nil); +} + +- (void)addTags:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSDictionary *tags = call.arguments; + [OneSignal.User addTags:tags]; + result(nil); +} + +- (void)removeTags:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSDictionary *tags = call.arguments; + [OneSignal.User removeTags:tags]; + result(nil); +} + +- (void)getTags:(FlutterMethodCall *)call withResult:(FlutterResult)result { + result([OneSignal.User getTags]); +} + +- (void)addEmail:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSString *email = call.arguments; + [OneSignal.User addEmail:email]; + result(nil); +} + +- (void)removeEmail:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSString *email = call.arguments; + [OneSignal.User removeEmail:email]; + result(nil); +} + +- (void)addSms:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSString *smsNumber = call.arguments; + [OneSignal.User addSms:smsNumber]; + result(nil); +} + +- (void)removeSms:(FlutterMethodCall *)call withResult:(FlutterResult)result { + NSString *smsNumber = call.arguments; + [OneSignal.User removeSms:smsNumber]; + result(nil); +} + +- (void)lifecycleInit:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + [OneSignal.User addObserver:self]; + result(nil); +} + +- (void)onUserStateDidChangeWithState:(OSUserChangedState *)state { + NSString *onesignalId = [self getStringOrNSNull:state.current.onesignalId]; + NSString *externalId = [self getStringOrNSNull:state.current.externalId]; + + NSMutableDictionary *result = [NSMutableDictionary new]; + + NSMutableDictionary *currentObject = [NSMutableDictionary new]; + + currentObject[@"onesignalId"] = onesignalId; + currentObject[@"externalId"] = externalId; + result[@"current"] = currentObject; + + [self.channel invokeMethod:@"OneSignal#onUserStateChange" arguments:result]; +} + +- (void)getOnesignalId:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + result(OneSignal.User.onesignalId); +} + +- (void)getExternalId:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + result(OneSignal.User.externalId); +} + +/** Helper method to return NSNull if string is empty or nil **/ +- (NSString *)getStringOrNSNull:(NSString *)string { + // length method can be used on nil and strings + if (string.length > 0) { + return string; + } else { + return [NSNull null]; + } +} +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/OneSignalPlugin.m b/ios/onesignal_flutter/Sources/onesignal_flutter/OneSignalPlugin.m new file mode 100644 index 00000000..e8e4b2d7 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/OneSignalPlugin.m @@ -0,0 +1,128 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "./include/onesignal_flutter/OneSignalPlugin.h" +#import "./include/onesignal_flutter/OSFlutterCategories.h" +#import "./include/onesignal_flutter/OSFlutterDebug.h" +#import "./include/onesignal_flutter/OSFlutterInAppMessages.h" +#import "./include/onesignal_flutter/OSFlutterLiveActivities.h" +#import "./include/onesignal_flutter/OSFlutterLocation.h" +#import "./include/onesignal_flutter/OSFlutterNotifications.h" +#import "./include/onesignal_flutter/OSFlutterSession.h" +#import "./include/onesignal_flutter/OSFlutterUser.h" + +@interface OneSignalPlugin () + +@property(strong, nonatomic) FlutterMethodChannel *channel; + +@end + +@implementation OneSignalPlugin + ++ (instancetype)sharedInstance { + static OneSignalPlugin *sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [OneSignalPlugin new]; + }); + return sharedInstance; +} + +#pragma mark FlutterPlugin ++ (void)registerWithRegistrar:(NSObject *)registrar { + + OneSignalWrapper.sdkType = @"flutter"; + OneSignalWrapper.sdkVersion = @"050305"; + [OneSignal initialize:nil withLaunchOptions:nil]; + + OneSignalPlugin.sharedInstance.channel = + [FlutterMethodChannel methodChannelWithName:@"OneSignal" + binaryMessenger:[registrar messenger]]; + + [registrar addMethodCallDelegate:OneSignalPlugin.sharedInstance + channel:OneSignalPlugin.sharedInstance.channel]; + [OSFlutterDebug registerWithRegistrar:registrar]; + [OSFlutterUser registerWithRegistrar:registrar]; + [OSFlutterNotifications registerWithRegistrar:registrar]; + [OSFlutterSession registerWithRegistrar:registrar]; + [OSFlutterLocation registerWithRegistrar:registrar]; + [OSFlutterInAppMessages registerWithRegistrar:registrar]; + [OSFlutterLiveActivities registerWithRegistrar:registrar]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call + result:(FlutterResult)result { + if ([@"OneSignal#initialize" isEqualToString:call.method]) + [self initialize:call withResult:result]; + else if ([@"OneSignal#login" isEqualToString:call.method]) + [self login:call withResult:result]; + else if ([@"OneSignal#logout" isEqualToString:call.method]) + [self logout:call withResult:result]; + else if ([@"OneSignal#consentRequired" isEqualToString:call.method]) + [self setConsentRequired:call withResult:result]; + else if ([@"OneSignal#consentGiven" isEqualToString:call.method]) + [self setConsentGiven:call withResult:result]; + else + result(FlutterMethodNotImplemented); +} + +#pragma mark Init + +- (void)initialize:(FlutterMethodCall *)call withResult:(FlutterResult)result { + [OneSignal initialize:call.arguments[@"appId"] withLaunchOptions:nil]; + result(nil); +} + +#pragma mark Login Logout + +- (void)login:(FlutterMethodCall *)call withResult:(FlutterResult)result { + [OneSignal login:call.arguments[@"externalId"]]; + result(nil); +} + +- (void)logout:(FlutterMethodCall *)call withResult:(FlutterResult)result { + [OneSignal logout]; + result(nil); +} + +#pragma mark Privacy Consent + +- (void)setConsentGiven:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + BOOL granted = [call.arguments[@"granted"] boolValue]; + [OneSignal setConsentGiven:granted]; + result(nil); +} + +- (void)setConsentRequired:(FlutterMethodCall *)call + withResult:(FlutterResult)result { + BOOL required = [call.arguments[@"required"] boolValue]; + [OneSignal setConsentRequired:required]; + result(nil); +} + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterCategories.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterCategories.h new file mode 100644 index 00000000..329e80b8 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterCategories.h @@ -0,0 +1,82 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import + +#ifndef OneSignalCategories_h +#define OneSignalCategories_h + +@interface OSNotification (Flutter) +- (NSDictionary *)toJson; +@end + +@interface OSNotificationWillDisplayEvent (Flutter) +- (NSDictionary *)toJson; +@end + +@interface OSNotificationClickEvent (Flutter) +- (NSDictionary *)toJson; +@end + +@interface OSNotificationClickResult (Flutter) +- (NSDictionary *)toJson; +@end + +@interface OSInAppMessage (Flutter) +- (NSDictionary *)toJson; +@end + +@interface NSError (Flutter) +- (FlutterError *)flutterError; +@end + +@interface OSInAppMessageWillDisplayEvent (Flutter) +- (NSDictionary *)toJson; +@end + +@interface OSInAppMessageDidDisplayEvent (Flutter) +- (NSDictionary *)toJson; +@end + +@interface OSInAppMessageWillDismissEvent (Flutter) +- (NSDictionary *)toJson; +@end + +@interface OSInAppMessageDidDismissEvent (Flutter) +- (NSDictionary *)toJson; +@end + +@interface OSInAppMessageClickEvent (Flutter) +- (NSDictionary *)toJson; +@end + +@interface OSInAppMessageClickResult (Flutter) +- (NSDictionary *)toJson; +@end + +#endif diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterDebug.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterDebug.h new file mode 100644 index 00000000..cbeeb147 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterDebug.h @@ -0,0 +1,35 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import + +@interface OSFlutterDebug : NSObject + +@property(strong, nonatomic) FlutterMethodChannel *channel; + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterInAppMessages.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterInAppMessages.h new file mode 100644 index 00000000..2ce71e51 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterInAppMessages.h @@ -0,0 +1,38 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import +#import + +@interface OSFlutterInAppMessages + : NSObject + +@property(strong, nonatomic) FlutterMethodChannel *channel; ++ (instancetype)sharedInstance; + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterLiveActivities.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterLiveActivities.h new file mode 100644 index 00000000..22313079 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterLiveActivities.h @@ -0,0 +1,35 @@ +/** + * Modified MIT License + * + * Copyright 2023 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import + +@interface OSFlutterLiveActivities : NSObject + +@property(strong, nonatomic) FlutterMethodChannel *channel; + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterLocation.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterLocation.h new file mode 100644 index 00000000..519a1d6a --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterLocation.h @@ -0,0 +1,35 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import + +@interface OSFlutterLocation : NSObject + +@property(strong, nonatomic) FlutterMethodChannel *channel; + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterNotifications.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterNotifications.h new file mode 100644 index 00000000..255248ca --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterNotifications.h @@ -0,0 +1,41 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import +#import + +@interface OSFlutterNotifications + : NSObject + +@property(strong, nonatomic) FlutterMethodChannel *channel; ++ (instancetype)sharedInstance; +@property(strong, nonatomic) NSMutableDictionary *onWillDisplayEventCache; +@property(strong, nonatomic) NSMutableDictionary *preventedDefaultCache; + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterPushSubscription.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterPushSubscription.h new file mode 100644 index 00000000..fe7c94fa --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterPushSubscription.h @@ -0,0 +1,38 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import +#import + +@interface OSFlutterPushSubscription + : NSObject + ++ (instancetype)sharedInstance; +@property(strong, nonatomic) FlutterMethodChannel *channel; + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterSession.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterSession.h new file mode 100644 index 00000000..0db13985 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterSession.h @@ -0,0 +1,35 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import + +@interface OSFlutterSession : NSObject + +@property(strong, nonatomic) FlutterMethodChannel *channel; + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterUser.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterUser.h new file mode 100644 index 00000000..67042f59 --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OSFlutterUser.h @@ -0,0 +1,35 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import + +@interface OSFlutterUser : NSObject + +@property(strong, nonatomic) FlutterMethodChannel *channel; + +@end diff --git a/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OneSignalPlugin.h b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OneSignalPlugin.h new file mode 100644 index 00000000..5b3fcb1e --- /dev/null +++ b/ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/OneSignalPlugin.h @@ -0,0 +1,36 @@ +/** + * Modified MIT License + * + * Copyright 2017 OneSignal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * 1. The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * 2. All copies of substantial portions of the Software may only be used in + * connection with services provided by OneSignal. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import +#import + +@interface OneSignalPlugin : NSObject + +// Do NOT initialize instances of this class. +// You must only reference the shared instance. ++ (instancetype)sharedInstance; +@end From 763875f412eb25aa4f8a229ef45e3e3caccc8e5e Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 7 Jan 2026 11:13:24 -0800 Subject: [PATCH 2/8] add OneSignalExtension --- ios/onesignal_flutter/Package.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ios/onesignal_flutter/Package.swift b/ios/onesignal_flutter/Package.swift index 8234d3bf..de879a8f 100644 --- a/ios/onesignal_flutter/Package.swift +++ b/ios/onesignal_flutter/Package.swift @@ -20,7 +20,8 @@ let package = Package( dependencies: [ .product(name: "OneSignalFramework", package: "OneSignal-XCFramework"), .product(name: "OneSignalInAppMessages", package: "OneSignal-XCFramework"), - .product(name: "OneSignalLocation", package: "OneSignal-XCFramework") + .product(name: "OneSignalLocation", package: "OneSignal-XCFramework"), + .product(name: "OneSignalExtension", package: "OneSignal-XCFramework") ], path: "Sources/onesignal_flutter" ) From e3d723c6631c3de94934fe0cee50135cddc2ace6 Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 7 Jan 2026 13:32:45 -0800 Subject: [PATCH 3/8] add request location example --- .gitignore | 3 --- example/ios/Runner/Info.plist | 2 ++ example/lib/main.dart | 27 ++++++++++++++++++++++++--- example_pod/ios/Runner/Info.plist | 2 ++ example_pod/lib/main.dart | 27 ++++++++++++++++++++++++--- example_spm/ios/Runner/Info.plist | 2 ++ example_spm/lib/main.dart | 27 ++++++++++++++++++++++++--- 7 files changed, 78 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index c8e3beb2..4ddccc77 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,3 @@ dlcov.log *.ipr *.iws .idea/ - -# Swift Package Manager -!.gitkeep diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index fa946f24..527f5f0f 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -33,6 +33,8 @@ NSSupportsLiveActivities + NSLocationWhenInUseUsageDescription + Your location is used to send relevant notifications. UIApplicationSupportsIndirectInputEvents UILaunchStoryboardName diff --git a/example/lib/main.dart b/example/lib/main.dart index b77b9201..d07bfe17 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -18,6 +18,7 @@ class _MyAppState extends State { String? _language; String? _liveActivityId; bool _enableConsentButton = false; + bool _locationShared = false; // CHANGE THIS parameter to true if you want to test GDPR privacy consent bool _requireConsent = false; @@ -197,8 +198,20 @@ class _MyAppState extends State { } void _handleSetLocationShared() { - print("Setting location shared to true"); - OneSignal.Location.setShared(true); + _locationShared = !_locationShared; + print("Setting location shared to $_locationShared"); + OneSignal.Location.setShared(_locationShared); + setState(() {}); + } + + void _handleRequestLocationPermission() { + print("Requesting location permission"); + OneSignal.Location.requestPermission(); + } + + void _handleIsLocationShared() async { + var isShared = await OneSignal.Location.isShared(); + print('Location shared: $isShared'); } void _handleGetExternalId() async { @@ -394,9 +407,17 @@ class _MyAppState extends State { _enableConsentButton) ]), new TableRow(children: [ - new OneSignalButton("Set Location Shared", + new OneSignalButton("Location Shared: $_locationShared", _handleSetLocationShared, !_enableConsentButton) ]), + new TableRow(children: [ + new OneSignalButton("Request Location", + _handleRequestLocationPermission, !_enableConsentButton) + ]), + new TableRow(children: [ + new OneSignalButton("Is Location Shared", + _handleIsLocationShared, !_enableConsentButton) + ]), new TableRow(children: [ new OneSignalButton( "Remove Tag", _handleRemoveTag, !_enableConsentButton) diff --git a/example_pod/ios/Runner/Info.plist b/example_pod/ios/Runner/Info.plist index fa946f24..527f5f0f 100644 --- a/example_pod/ios/Runner/Info.plist +++ b/example_pod/ios/Runner/Info.plist @@ -33,6 +33,8 @@ NSSupportsLiveActivities + NSLocationWhenInUseUsageDescription + Your location is used to send relevant notifications. UIApplicationSupportsIndirectInputEvents UILaunchStoryboardName diff --git a/example_pod/lib/main.dart b/example_pod/lib/main.dart index b77b9201..d07bfe17 100644 --- a/example_pod/lib/main.dart +++ b/example_pod/lib/main.dart @@ -18,6 +18,7 @@ class _MyAppState extends State { String? _language; String? _liveActivityId; bool _enableConsentButton = false; + bool _locationShared = false; // CHANGE THIS parameter to true if you want to test GDPR privacy consent bool _requireConsent = false; @@ -197,8 +198,20 @@ class _MyAppState extends State { } void _handleSetLocationShared() { - print("Setting location shared to true"); - OneSignal.Location.setShared(true); + _locationShared = !_locationShared; + print("Setting location shared to $_locationShared"); + OneSignal.Location.setShared(_locationShared); + setState(() {}); + } + + void _handleRequestLocationPermission() { + print("Requesting location permission"); + OneSignal.Location.requestPermission(); + } + + void _handleIsLocationShared() async { + var isShared = await OneSignal.Location.isShared(); + print('Location shared: $isShared'); } void _handleGetExternalId() async { @@ -394,9 +407,17 @@ class _MyAppState extends State { _enableConsentButton) ]), new TableRow(children: [ - new OneSignalButton("Set Location Shared", + new OneSignalButton("Location Shared: $_locationShared", _handleSetLocationShared, !_enableConsentButton) ]), + new TableRow(children: [ + new OneSignalButton("Request Location", + _handleRequestLocationPermission, !_enableConsentButton) + ]), + new TableRow(children: [ + new OneSignalButton("Is Location Shared", + _handleIsLocationShared, !_enableConsentButton) + ]), new TableRow(children: [ new OneSignalButton( "Remove Tag", _handleRemoveTag, !_enableConsentButton) diff --git a/example_spm/ios/Runner/Info.plist b/example_spm/ios/Runner/Info.plist index fa946f24..527f5f0f 100644 --- a/example_spm/ios/Runner/Info.plist +++ b/example_spm/ios/Runner/Info.plist @@ -33,6 +33,8 @@ NSSupportsLiveActivities + NSLocationWhenInUseUsageDescription + Your location is used to send relevant notifications. UIApplicationSupportsIndirectInputEvents UILaunchStoryboardName diff --git a/example_spm/lib/main.dart b/example_spm/lib/main.dart index b77b9201..d07bfe17 100644 --- a/example_spm/lib/main.dart +++ b/example_spm/lib/main.dart @@ -18,6 +18,7 @@ class _MyAppState extends State { String? _language; String? _liveActivityId; bool _enableConsentButton = false; + bool _locationShared = false; // CHANGE THIS parameter to true if you want to test GDPR privacy consent bool _requireConsent = false; @@ -197,8 +198,20 @@ class _MyAppState extends State { } void _handleSetLocationShared() { - print("Setting location shared to true"); - OneSignal.Location.setShared(true); + _locationShared = !_locationShared; + print("Setting location shared to $_locationShared"); + OneSignal.Location.setShared(_locationShared); + setState(() {}); + } + + void _handleRequestLocationPermission() { + print("Requesting location permission"); + OneSignal.Location.requestPermission(); + } + + void _handleIsLocationShared() async { + var isShared = await OneSignal.Location.isShared(); + print('Location shared: $isShared'); } void _handleGetExternalId() async { @@ -394,9 +407,17 @@ class _MyAppState extends State { _enableConsentButton) ]), new TableRow(children: [ - new OneSignalButton("Set Location Shared", + new OneSignalButton("Location Shared: $_locationShared", _handleSetLocationShared, !_enableConsentButton) ]), + new TableRow(children: [ + new OneSignalButton("Request Location", + _handleRequestLocationPermission, !_enableConsentButton) + ]), + new TableRow(children: [ + new OneSignalButton("Is Location Shared", + _handleIsLocationShared, !_enableConsentButton) + ]), new TableRow(children: [ new OneSignalButton( "Remove Tag", _handleRemoveTag, !_enableConsentButton) From 5b177d0dfe1183e1e9d2b58165131c794544a8ca Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 7 Jan 2026 14:11:49 -0800 Subject: [PATCH 4/8] add csettings --- ios/onesignal_flutter/Package.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ios/onesignal_flutter/Package.swift b/ios/onesignal_flutter/Package.swift index de879a8f..d1a2133a 100644 --- a/ios/onesignal_flutter/Package.swift +++ b/ios/onesignal_flutter/Package.swift @@ -23,7 +23,10 @@ let package = Package( .product(name: "OneSignalLocation", package: "OneSignal-XCFramework"), .product(name: "OneSignalExtension", package: "OneSignal-XCFramework") ], - path: "Sources/onesignal_flutter" - ) + path: "Sources/onesignal_flutter", + cSettings: [ + .headerSearchPath("include/onesignal_flutter"), + ] + ), ] ) From f662f774cf2583a856c262f21f9c064fe80d9bd4 Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 7 Jan 2026 14:18:05 -0800 Subject: [PATCH 5/8] update release automation to update package swift version --- .github/workflows/create-release-pr.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 1e68fad9..43dc69eb 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -142,6 +142,10 @@ jobs: sed -i '' "s|s.dependency 'OneSignalXCFramework', '[^']*'|s.dependency 'OneSignalXCFramework', '${VERSION}'|" ios/onesignal_flutter.podspec echo "✓ Updated ios/onesignal_flutter.podspec with iOS SDK ${VERSION}" + # Update Package.swift with new version (for SPM) + sed -i '' "s|OneSignal-XCFramework\", exact: \"[^\"]*\"|OneSignal-XCFramework\", exact: \"${VERSION}\"|" ios/onesignal_flutter/Package.swift + echo "✓ Updated ios/onesignal_flutter/Package.swift with iOS SDK ${VERSION}" + # Update ios example cd example/ios pod update OneSignalXCFramework From e549c960556d0511aa846dd1f23b5bf47ed6a8a5 Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 7 Jan 2026 14:22:27 -0800 Subject: [PATCH 6/8] remove classes --- ios/Classes/OSFlutterCategories.h | 82 --------- ios/Classes/OSFlutterCategories.m | 206 ---------------------- ios/Classes/OSFlutterDebug.h | 35 ---- ios/Classes/OSFlutterDebug.m | 68 -------- ios/Classes/OSFlutterInAppMessages.h | 38 ---- ios/Classes/OSFlutterInAppMessages.m | 144 --------------- ios/Classes/OSFlutterLiveActivities.h | 35 ---- ios/Classes/OSFlutterLiveActivities.m | 189 -------------------- ios/Classes/OSFlutterLocation.h | 35 ---- ios/Classes/OSFlutterLocation.m | 68 -------- ios/Classes/OSFlutterNotifications.h | 41 ----- ios/Classes/OSFlutterNotifications.m | 221 ------------------------ ios/Classes/OSFlutterPushSubscription.h | 38 ---- ios/Classes/OSFlutterPushSubscription.m | 85 --------- ios/Classes/OSFlutterSession.h | 35 ---- ios/Classes/OSFlutterSession.m | 77 --------- ios/Classes/OSFlutterUser.h | 35 ---- ios/Classes/OSFlutterUser.m | 180 ------------------- ios/Classes/OneSignalPlugin.h | 36 ---- ios/Classes/OneSignalPlugin.m | 128 -------------- 20 files changed, 1776 deletions(-) delete mode 100644 ios/Classes/OSFlutterCategories.h delete mode 100644 ios/Classes/OSFlutterCategories.m delete mode 100644 ios/Classes/OSFlutterDebug.h delete mode 100644 ios/Classes/OSFlutterDebug.m delete mode 100644 ios/Classes/OSFlutterInAppMessages.h delete mode 100644 ios/Classes/OSFlutterInAppMessages.m delete mode 100644 ios/Classes/OSFlutterLiveActivities.h delete mode 100644 ios/Classes/OSFlutterLiveActivities.m delete mode 100644 ios/Classes/OSFlutterLocation.h delete mode 100644 ios/Classes/OSFlutterLocation.m delete mode 100644 ios/Classes/OSFlutterNotifications.h delete mode 100644 ios/Classes/OSFlutterNotifications.m delete mode 100644 ios/Classes/OSFlutterPushSubscription.h delete mode 100644 ios/Classes/OSFlutterPushSubscription.m delete mode 100644 ios/Classes/OSFlutterSession.h delete mode 100644 ios/Classes/OSFlutterSession.m delete mode 100644 ios/Classes/OSFlutterUser.h delete mode 100644 ios/Classes/OSFlutterUser.m delete mode 100644 ios/Classes/OneSignalPlugin.h delete mode 100644 ios/Classes/OneSignalPlugin.m diff --git a/ios/Classes/OSFlutterCategories.h b/ios/Classes/OSFlutterCategories.h deleted file mode 100644 index 329e80b8..00000000 --- a/ios/Classes/OSFlutterCategories.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import - -#ifndef OneSignalCategories_h -#define OneSignalCategories_h - -@interface OSNotification (Flutter) -- (NSDictionary *)toJson; -@end - -@interface OSNotificationWillDisplayEvent (Flutter) -- (NSDictionary *)toJson; -@end - -@interface OSNotificationClickEvent (Flutter) -- (NSDictionary *)toJson; -@end - -@interface OSNotificationClickResult (Flutter) -- (NSDictionary *)toJson; -@end - -@interface OSInAppMessage (Flutter) -- (NSDictionary *)toJson; -@end - -@interface NSError (Flutter) -- (FlutterError *)flutterError; -@end - -@interface OSInAppMessageWillDisplayEvent (Flutter) -- (NSDictionary *)toJson; -@end - -@interface OSInAppMessageDidDisplayEvent (Flutter) -- (NSDictionary *)toJson; -@end - -@interface OSInAppMessageWillDismissEvent (Flutter) -- (NSDictionary *)toJson; -@end - -@interface OSInAppMessageDidDismissEvent (Flutter) -- (NSDictionary *)toJson; -@end - -@interface OSInAppMessageClickEvent (Flutter) -- (NSDictionary *)toJson; -@end - -@interface OSInAppMessageClickResult (Flutter) -- (NSDictionary *)toJson; -@end - -#endif diff --git a/ios/Classes/OSFlutterCategories.m b/ios/Classes/OSFlutterCategories.m deleted file mode 100644 index db3ac0ec..00000000 --- a/ios/Classes/OSFlutterCategories.m +++ /dev/null @@ -1,206 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "OSFlutterCategories.h" - -/* - The OneSignal iOS SDK implements similar methods (`toDictionary`) - However we decided to implement custom `toJson` methods for several - of these objects to add more properties. - - TODO: Update the native iOS SDK to add these details - (ie. `templateId` is missing from OSNotificationPayload's `toDictionary` - method in the native SDK) and remove them from here. -*/ - -@implementation OSNotification (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"contentAvailable"] = @(self.contentAvailable); - json[@"mutableContent"] = @(self.mutableContent); - - if (self.rawPayload) { - NSError *jsonError; - NSData *data = - [NSJSONSerialization dataWithJSONObject:self.rawPayload - options:NSJSONWritingPrettyPrinted - error:&jsonError]; - - if (!jsonError) { - NSString *rawPayloadString = - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - json[@"rawPayload"] = rawPayloadString; - } - } - - if (self.notificationId) - json[@"notificationId"] = self.notificationId; - if (self.templateName) - json[@"templateName"] = self.templateName; - if (self.templateId) - json[@"templateId"] = self.templateId; - if (self.badge) - json[@"badge"] = @(self.badge); - if (self.badgeIncrement) - json[@"badgeIncrement"] = @(self.badgeIncrement); - if (self.sound) - json[@"sound"] = self.sound; - if (self.title) - json[@"title"] = self.title; - if (self.subtitle) - json[@"subtitle"] = self.subtitle; - if (self.body) - json[@"body"] = self.body; - if (self.launchURL) - json[@"launchUrl"] = self.launchURL; - if (self.additionalData) - json[@"additionalData"] = self.additionalData; - if (self.attachments) - json[@"attachments"] = self.attachments; - if (self.actionButtons) - json[@"buttons"] = self.actionButtons; - if (self.category) - json[@"category"] = self.category; - - return json; -} -@end - -@implementation OSNotificationClickEvent (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"notification"] = self.notification.toJson; - json[@"result"] = self.result.toJson; - - return json; -} -@end - -@implementation OSNotificationClickResult (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"action_id"] = self.actionId; - json[@"url"] = self.url; - - return json; -} -@end - -@implementation OSNotificationWillDisplayEvent (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"notification"] = self.notification.toJson; - - return json; -} -@end - -@implementation OSInAppMessageWillDisplayEvent (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"message"] = self.message.toJson; - - return json; -} -@end - -@implementation OSInAppMessageDidDisplayEvent (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"message"] = self.message.toJson; - - return json; -} -@end - -@implementation OSInAppMessageWillDismissEvent (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"message"] = self.message.toJson; - - return json; -} -@end - -@implementation OSInAppMessageDidDismissEvent (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"message"] = self.message.toJson; - - return json; -} -@end - -@implementation OSInAppMessageClickEvent (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"message"] = self.message.toJson; - json[@"result"] = self.result.toJson; - - return json; -} -@end - -@implementation OSInAppMessageClickResult (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"action_id"] = self.actionId; - json[@"url"] = self.url; - json[@"closing_message"] = @(self.closingMessage); - - return json; -} -@end - -@implementation OSInAppMessage (Flutter) -- (NSDictionary *)toJson { - NSMutableDictionary *json = [NSMutableDictionary new]; - - json[@"message_id"] = self.messageId; - - return json; -} -@end - -@implementation NSError (Flutter) -- (FlutterError *)flutterError { - return [FlutterError - errorWithCode:[NSString stringWithFormat:@"%i", (int)self.code] - message:self.localizedDescription - details:nil]; -} -@end diff --git a/ios/Classes/OSFlutterDebug.h b/ios/Classes/OSFlutterDebug.h deleted file mode 100644 index cbeeb147..00000000 --- a/ios/Classes/OSFlutterDebug.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import - -@interface OSFlutterDebug : NSObject - -@property(strong, nonatomic) FlutterMethodChannel *channel; - -@end diff --git a/ios/Classes/OSFlutterDebug.m b/ios/Classes/OSFlutterDebug.m deleted file mode 100644 index f443157a..00000000 --- a/ios/Classes/OSFlutterDebug.m +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "OSFlutterDebug.h" -#import "OSFlutterCategories.h" -#import - -@implementation OSFlutterDebug -+ (void)registerWithRegistrar:(NSObject *)registrar { - OSFlutterDebug *instance = [OSFlutterDebug new]; - - instance.channel = - [FlutterMethodChannel methodChannelWithName:@"OneSignal#debug" - binaryMessenger:[registrar messenger]]; - - [registrar addMethodCallDelegate:instance channel:instance.channel]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call - result:(FlutterResult)result { - if ([@"OneSignal#setLogLevel" isEqualToString:call.method]) - [self setLogLevel:call withResult:result]; - else if ([@"OneSignal#setAlertLevel" isEqualToString:call.method]) - [self setAlertLevel:call withResult:result]; - else - result(FlutterMethodNotImplemented); -} - -- (void)setLogLevel:(FlutterMethodCall *)call withResult:(FlutterResult)result { - ONE_S_LOG_LEVEL logLevel = - (ONE_S_LOG_LEVEL)[call.arguments[@"logLevel"] intValue]; - [OneSignal.Debug setLogLevel:logLevel]; - result(nil); -} - -- (void)setAlertLevel:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - ONE_S_LOG_LEVEL visualLogLevel = - (ONE_S_LOG_LEVEL)[call.arguments[@"visualLevel"] intValue]; - [OneSignal.Debug setAlertLevel:visualLogLevel]; - result(nil); -} - -@end diff --git a/ios/Classes/OSFlutterInAppMessages.h b/ios/Classes/OSFlutterInAppMessages.h deleted file mode 100644 index 2ce71e51..00000000 --- a/ios/Classes/OSFlutterInAppMessages.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import -#import - -@interface OSFlutterInAppMessages - : NSObject - -@property(strong, nonatomic) FlutterMethodChannel *channel; -+ (instancetype)sharedInstance; - -@end diff --git a/ios/Classes/OSFlutterInAppMessages.m b/ios/Classes/OSFlutterInAppMessages.m deleted file mode 100644 index a8f538a3..00000000 --- a/ios/Classes/OSFlutterInAppMessages.m +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "OSFlutterInAppMessages.h" -#import "OSFlutterCategories.h" -#import - -@implementation OSFlutterInAppMessages - -+ (instancetype)sharedInstance { - static OSFlutterInAppMessages *sharedInstance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedInstance = [OSFlutterInAppMessages new]; - }); - return sharedInstance; -} - -+ (void)registerWithRegistrar:(NSObject *)registrar { - - OSFlutterInAppMessages.sharedInstance.channel = - [FlutterMethodChannel methodChannelWithName:@"OneSignal#inappmessages" - binaryMessenger:[registrar messenger]]; - - [registrar - addMethodCallDelegate:OSFlutterInAppMessages.sharedInstance - channel:OSFlutterInAppMessages.sharedInstance.channel]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call - result:(FlutterResult)result { - if ([@"OneSignal#addTrigger" isEqualToString:call.method]) - [self addTriggers:call withResult:result]; - else if ([@"OneSignal#addTriggers" isEqualToString:call.method]) - [self addTriggers:call withResult:result]; - else if ([@"OneSignal#removeTrigger" isEqualToString:call.method]) - [self removeTrigger:call withResult:result]; - else if ([@"OneSignal#removeTriggers" isEqualToString:call.method]) - [self removeTriggers:call withResult:result]; - else if ([@"OneSignal#clearTriggers" isEqualToString:call.method]) - [self clearTriggers:call withResult:result]; - else if ([@"OneSignal#paused" isEqualToString:call.method]) - [self paused:call withResult:result]; - else if ([@"OneSignal#arePaused" isEqualToString:call.method]) - result(@([OneSignal.InAppMessages paused])); - else if ([@"OneSignal#lifecycleInit" isEqualToString:call.method]) - [self lifecycleInit:call withResult:result]; - else - result(FlutterMethodNotImplemented); -} - -- (void)addTriggers:(FlutterMethodCall *)call withResult:(FlutterResult)result { - NSDictionary *triggers = call.arguments; - [OneSignal.InAppMessages addTriggers:triggers]; - result(nil); -} - -- (void)removeTrigger:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSString *key = call.arguments; - [OneSignal.InAppMessages removeTrigger:key]; - result(nil); -} - -- (void)removeTriggers:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSArray *keys = call.arguments; - [OneSignal.InAppMessages removeTriggers:keys]; - result(nil); -} - -- (void)clearTriggers:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - [OneSignal.InAppMessages clearTriggers]; - result(nil); -} - -- (void)paused:(FlutterMethodCall *)call withResult:(FlutterResult)result { - BOOL pause = [call.arguments boolValue]; - [OneSignal.InAppMessages paused:pause]; - result(nil); -} - -- (void)lifecycleInit:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - [OneSignal.InAppMessages - addClickListener:OSFlutterInAppMessages.sharedInstance]; - [OneSignal.InAppMessages - addLifecycleListener:OSFlutterInAppMessages.sharedInstance]; -} - -#pragma mark In App Message Click - -- (void)onClickInAppMessage:(OSInAppMessageClickEvent *_Nonnull)event { - [self.channel invokeMethod:@"OneSignal#onClickInAppMessage" - arguments:event.toJson]; -} - -#pragma mark OSInAppMessageLifecycleListener -- (void)onWillDisplayInAppMessage:(OSInAppMessageWillDisplayEvent *)event { - [self.channel invokeMethod:@"OneSignal#onWillDisplayInAppMessage" - arguments:event.toJson]; -} - -- (void)onDidDisplayInAppMessage:(OSInAppMessageDidDisplayEvent *)event { - [self.channel invokeMethod:@"OneSignal#onDidDisplayInAppMessage" - arguments:event.toJson]; -} - -- (void)onWillDismissInAppMessage:(OSInAppMessageWillDismissEvent *)event { - [self.channel invokeMethod:@"OneSignal#onWillDismissInAppMessage" - arguments:event.toJson]; -} - -- (void)onDidDismissInAppMessage:(OSInAppMessageDidDismissEvent *)event { - [self.channel invokeMethod:@"OneSignal#onDidDismissInAppMessage" - arguments:event.toJson]; -} - -@end diff --git a/ios/Classes/OSFlutterLiveActivities.h b/ios/Classes/OSFlutterLiveActivities.h deleted file mode 100644 index 22313079..00000000 --- a/ios/Classes/OSFlutterLiveActivities.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import - -@interface OSFlutterLiveActivities : NSObject - -@property(strong, nonatomic) FlutterMethodChannel *channel; - -@end diff --git a/ios/Classes/OSFlutterLiveActivities.m b/ios/Classes/OSFlutterLiveActivities.m deleted file mode 100644 index aa2a1f80..00000000 --- a/ios/Classes/OSFlutterLiveActivities.m +++ /dev/null @@ -1,189 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "OSFlutterLiveActivities.h" -#import "OSFlutterCategories.h" -#import "OneSignalLiveActivities/OneSignalLiveActivities-Swift.h" -#import - -@implementation OSFlutterLiveActivities -+ (void)registerWithRegistrar:(NSObject *)registrar { - OSFlutterLiveActivities *instance = [OSFlutterLiveActivities new]; - - instance.channel = - [FlutterMethodChannel methodChannelWithName:@"OneSignal#liveactivities" - binaryMessenger:[registrar messenger]]; - - [registrar addMethodCallDelegate:instance channel:instance.channel]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call - result:(FlutterResult)result { - if ([@"OneSignal#enterLiveActivity" isEqualToString:call.method]) - [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); -} - -- (void)enterLiveActivity:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSString *activityId = call.arguments[@"activityId"]; - NSString *token = call.arguments[@"token"]; - - [OneSignal.LiveActivities enter:activityId - withToken:token - withSuccess:^(NSDictionary *results) { - result(results); - } - withFailure:^(NSError *error) { - result(error.flutterError); - }]; -} - -- (void)exitLiveActivity:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSString *activityId = call.arguments[@"activityId"]; - - [OneSignal.LiveActivities exit:activityId - withSuccess:^(NSDictionary *results) { - result(results); - } - withFailure:^(NSError *error) { - result(error.flutterError); - }]; -} - -- (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/Classes/OSFlutterLocation.h b/ios/Classes/OSFlutterLocation.h deleted file mode 100644 index 519a1d6a..00000000 --- a/ios/Classes/OSFlutterLocation.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import - -@interface OSFlutterLocation : NSObject - -@property(strong, nonatomic) FlutterMethodChannel *channel; - -@end diff --git a/ios/Classes/OSFlutterLocation.m b/ios/Classes/OSFlutterLocation.m deleted file mode 100644 index 1d0d46fd..00000000 --- a/ios/Classes/OSFlutterLocation.m +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "OSFlutterLocation.h" -#import "OSFlutterCategories.h" -#import - -@implementation OSFlutterLocation -+ (void)registerWithRegistrar:(NSObject *)registrar { - OSFlutterLocation *instance = [OSFlutterLocation new]; - - instance.channel = - [FlutterMethodChannel methodChannelWithName:@"OneSignal#location" - binaryMessenger:[registrar messenger]]; - - [registrar addMethodCallDelegate:instance channel:instance.channel]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call - result:(FlutterResult)result { - if ([@"OneSignal#requestPermission" isEqualToString:call.method]) - [self requestPermission:call withResult:result]; - else if ([@"OneSignal#setShared" isEqualToString:call.method]) - [self setLocationShared:call withResult:result]; - else if ([@"OneSignal#isShared" isEqualToString:call.method]) - result(@([OneSignal.Location isShared])); - else - result(FlutterMethodNotImplemented); -} - -- (void)setLocationShared:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - BOOL locationShared = [call.arguments boolValue]; - [OneSignal.Location setShared:locationShared]; - result(nil); -} - -- (void)requestPermission:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - [OneSignal.Location requestPermission]; - result(nil); -} - -@end diff --git a/ios/Classes/OSFlutterNotifications.h b/ios/Classes/OSFlutterNotifications.h deleted file mode 100644 index 255248ca..00000000 --- a/ios/Classes/OSFlutterNotifications.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import -#import - -@interface OSFlutterNotifications - : NSObject - -@property(strong, nonatomic) FlutterMethodChannel *channel; -+ (instancetype)sharedInstance; -@property(strong, nonatomic) NSMutableDictionary *onWillDisplayEventCache; -@property(strong, nonatomic) NSMutableDictionary *preventedDefaultCache; - -@end diff --git a/ios/Classes/OSFlutterNotifications.m b/ios/Classes/OSFlutterNotifications.m deleted file mode 100644 index 242ee4b4..00000000 --- a/ios/Classes/OSFlutterNotifications.m +++ /dev/null @@ -1,221 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "OSFlutterNotifications.h" -#import "OSFlutterCategories.h" -#import -#import - -@implementation OSFlutterNotifications - -+ (instancetype)sharedInstance { - static OSFlutterNotifications *sharedInstance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedInstance = [OSFlutterNotifications new]; - sharedInstance.onWillDisplayEventCache = [NSMutableDictionary new]; - sharedInstance.preventedDefaultCache = [NSMutableDictionary new]; - }); - return sharedInstance; -} - -+ (void)registerWithRegistrar:(NSObject *)registrar { - - OSFlutterNotifications.sharedInstance.channel = - [FlutterMethodChannel methodChannelWithName:@"OneSignal#notifications" - binaryMessenger:[registrar messenger]]; - - [registrar - addMethodCallDelegate:OSFlutterNotifications.sharedInstance - channel:OSFlutterNotifications.sharedInstance.channel]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call - result:(FlutterResult)result { - if ([@"OneSignal#permission" isEqualToString:call.method]) - result(@([OneSignal.Notifications permission])); - else if ([@"OneSignal#permissionNative" isEqualToString:call.method]) - [self permissionNative:call withResult:result]; - else if ([@"OneSignal#canRequest" isEqualToString:call.method]) - result(@([OneSignal.Notifications canRequestPermission])); - else if ([@"OneSignal#clearAll" isEqualToString:call.method]) - [self clearAll:call withResult:result]; - else if ([@"OneSignal#requestPermission" isEqualToString:call.method]) - [self requestPermission:call withResult:result]; - else if ([@"OneSignal#registerForProvisionalAuthorization" - isEqualToString:call.method]) - [self registerForProvisionalAuthorization:call withResult:result]; - else if ([@"OneSignal#displayNotification" isEqualToString:call.method]) - [self displayNotification:call withResult:result]; - else if ([@"OneSignal#preventDefault" isEqualToString:call.method]) - [self preventDefault:call withResult:result]; - else if ([@"OneSignal#lifecycleInit" isEqualToString:call.method]) - [self lifecycleInit:call withResult:result]; - else if ([@"OneSignal#proceedWithWillDisplay" isEqualToString:call.method]) - [self proceedWithWillDisplay:call withResult:result]; - else if ([@"OneSignal#addNativeClickListener" isEqualToString:call.method]) - [self registerClickListener:call withResult:result]; - else - result(FlutterMethodNotImplemented); -} - -- (void)permissionNative:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - OSNotificationPermission permission = - [OneSignal.Notifications permissionNative]; - result(@((int)permission)); -} - -- (void)clearAll:(FlutterMethodCall *)call withResult:(FlutterResult)result { - [OneSignal.Notifications clearAll]; - result(nil); -} - -- (void)requestPermission:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - BOOL fallbackToSettings = [call.arguments[@"fallbackToSettings"] boolValue]; - - [OneSignal.Notifications - requestPermission:^(BOOL accepted) { - result(@(accepted)); - } - fallbackToSettings:fallbackToSettings]; -} - -- (void)registerForProvisionalAuthorization:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - [OneSignal.Notifications - registerForProvisionalAuthorization:^(BOOL accepted) { - result(@(accepted)); - }]; -} - -- (void)lifecycleInit:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - [OneSignal.Notifications addForegroundLifecycleListener:self]; - [OneSignal.Notifications addPermissionObserver:self]; - result(nil); -} - -- (void)registerClickListener:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - [OneSignal.Notifications addClickListener:self]; - result(nil); -} - -- (void)onNotificationPermissionDidChange:(BOOL)permission { - [self.channel invokeMethod:@"OneSignal#onNotificationPermissionDidChange" - arguments:@{@"permission" : @(permission)}]; -} - -#pragma mark Received in Notification Lifecycle Event - -- (void)onWillDisplayNotification:(OSNotificationWillDisplayEvent *)event { - self.onWillDisplayEventCache[event.notification.notificationId] = event; - /// Our bridge layer needs to preventDefault so that the Flutter listener has - /// time to preventDefault before the notification is displayed - [event preventDefault]; - [self.channel invokeMethod:@"OneSignal#onWillDisplayNotification" - arguments:event.toJson]; -} - -/// Our bridge layer needs to preventDefault so that the Flutter listener has -/// time to preventDefault before the notification is displayed This function is -/// called after all of the flutter listeners have responded to the willDisplay -/// event. If any of them have called preventDefault we will not call display(). -/// Otherwise we will display. -- (void)proceedWithWillDisplay:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSString *notificationId = call.arguments[@"notificationId"]; - OSNotificationWillDisplayEvent *event = - self.onWillDisplayEventCache[notificationId]; - if (!event) { - [OneSignalLog - onesignalLog:ONE_S_LL_ERROR - message:[NSString - stringWithFormat: - @"OneSignal (objc): could not find notification " - @"will display event for notification with id: %@", - notificationId]]; - return; - } - if (self.preventedDefaultCache[notificationId]) { - return; - } - [event.notification display]; - result(nil); -} - -- (void)preventDefault:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSString *notificationId = call.arguments[@"notificationId"]; - OSNotificationWillDisplayEvent *event = - self.onWillDisplayEventCache[notificationId]; - - if (!event) { - [OneSignalLog - onesignalLog:ONE_S_LL_ERROR - message:[NSString - stringWithFormat: - @"OneSignal (objc): could not find notification " - @"will display event for notification with id: %@", - notificationId]]; - return; - } - [event preventDefault]; - self.preventedDefaultCache[event.notification.notificationId] = event; - result(nil); -} - -- (void)displayNotification:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSString *notificationId = call.arguments[@"notificationId"]; - OSNotificationWillDisplayEvent *event = - self.onWillDisplayEventCache[notificationId]; - - if (!event) { - [OneSignalLog - onesignalLog:ONE_S_LL_ERROR - message:[NSString - stringWithFormat: - @"OneSignal (objc): could not find notification " - @"will display event for notification with id: %@", - notificationId]]; - return; - } - [event.notification display]; - result(nil); -} - -#pragma mark Notification Click - -- (void)onClickNotification:(OSNotificationClickEvent *_Nonnull)event { - [self.channel invokeMethod:@"OneSignal#onClickNotification" - arguments:event.toJson]; -} - -@end diff --git a/ios/Classes/OSFlutterPushSubscription.h b/ios/Classes/OSFlutterPushSubscription.h deleted file mode 100644 index fe7c94fa..00000000 --- a/ios/Classes/OSFlutterPushSubscription.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import -#import - -@interface OSFlutterPushSubscription - : NSObject - -+ (instancetype)sharedInstance; -@property(strong, nonatomic) FlutterMethodChannel *channel; - -@end diff --git a/ios/Classes/OSFlutterPushSubscription.m b/ios/Classes/OSFlutterPushSubscription.m deleted file mode 100644 index 45b41aa2..00000000 --- a/ios/Classes/OSFlutterPushSubscription.m +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "OSFlutterPushSubscription.h" -#import "OSFlutterCategories.h" -#import -#import - -@implementation OSFlutterPushSubscription - -+ (void)registerWithRegistrar:(NSObject *)registrar { - OSFlutterPushSubscription *instance = [OSFlutterPushSubscription new]; - - instance.channel = - [FlutterMethodChannel methodChannelWithName:@"OneSignal#pushsubscription" - binaryMessenger:[registrar messenger]]; - - [registrar addMethodCallDelegate:instance channel:instance.channel]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call - result:(FlutterResult)result { - if ([@"OneSignal#pushSubscriptionId" isEqualToString:call.method]) - result(OneSignal.User.pushSubscription.id); - else if ([@"OneSignal#pushSubscriptionToken" isEqualToString:call.method]) - result(OneSignal.User.pushSubscription.token); - else if ([@"OneSignal#pushSubscriptionOptedIn" isEqualToString:call.method]) - result(@(OneSignal.User.pushSubscription.optedIn)); - else if ([@"OneSignal#optIn" isEqualToString:call.method]) - [self optIn:call withResult:result]; - else if ([@"OneSignal#optOut" isEqualToString:call.method]) - [self optOut:call withResult:result]; - else if ([@"OneSignal#lifecycleInit" isEqualToString:call.method]) - [self lifecycleInit:call withResult:result]; - else - result(FlutterMethodNotImplemented); -} - -- (void)optIn:(FlutterMethodCall *)call withResult:(FlutterResult)result { - [OneSignal.User.pushSubscription optIn]; - result(nil); -} - -- (void)optOut:(FlutterMethodCall *)call withResult:(FlutterResult)result { - [OneSignal.User.pushSubscription optOut]; - result(nil); -} - -- (void)lifecycleInit:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - [OneSignal.User.pushSubscription addObserver:self]; - result(nil); -} - -- (void)onPushSubscriptionDidChangeWithState: - (OSPushSubscriptionChangedState *)state { - [self.channel invokeMethod:@"OneSignal#onPushSubscriptionChange" - arguments:state.jsonRepresentation]; -} - -@end diff --git a/ios/Classes/OSFlutterSession.h b/ios/Classes/OSFlutterSession.h deleted file mode 100644 index 0db13985..00000000 --- a/ios/Classes/OSFlutterSession.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import - -@interface OSFlutterSession : NSObject - -@property(strong, nonatomic) FlutterMethodChannel *channel; - -@end diff --git a/ios/Classes/OSFlutterSession.m b/ios/Classes/OSFlutterSession.m deleted file mode 100644 index a5aa511a..00000000 --- a/ios/Classes/OSFlutterSession.m +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "OSFlutterSession.h" -#import "OSFlutterCategories.h" -#import - -@implementation OSFlutterSession -+ (void)registerWithRegistrar:(NSObject *)registrar { - OSFlutterSession *instance = [OSFlutterSession new]; - - instance.channel = - [FlutterMethodChannel methodChannelWithName:@"OneSignal#session" - binaryMessenger:[registrar messenger]]; - - [registrar addMethodCallDelegate:instance channel:instance.channel]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call - result:(FlutterResult)result { - if ([@"OneSignal#addOutcome" isEqualToString:call.method]) { - [self addOutcome:call withResult:result]; - } else if ([@"OneSignal#addUniqueOutcome" isEqualToString:call.method]) { - [self addUniqueOutcome:call withResult:result]; - } else if ([@"OneSignal#addOutcomeWithValue" isEqualToString:call.method]) { - [self addOutcomeWithValue:call withResult:result]; - } else { - result(FlutterMethodNotImplemented); - } -} - -- (void)addOutcome:(FlutterMethodCall *)call withResult:(FlutterResult)result { - NSString *name = call.arguments; - [OneSignal.Session addOutcome:name]; - result(nil); -} - -- (void)addUniqueOutcome:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSString *name = call.arguments; - [OneSignal.Session addUniqueOutcome:name]; - result(nil); -} - -- (void)addOutcomeWithValue:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSString *name = call.arguments[@"outcome_name"]; - NSNumber *value = call.arguments[@"outcome_value"]; - [OneSignal.Session addOutcomeWithValue:name value:value]; - result(nil); -} - -@end diff --git a/ios/Classes/OSFlutterUser.h b/ios/Classes/OSFlutterUser.h deleted file mode 100644 index 67042f59..00000000 --- a/ios/Classes/OSFlutterUser.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import - -@interface OSFlutterUser : NSObject - -@property(strong, nonatomic) FlutterMethodChannel *channel; - -@end diff --git a/ios/Classes/OSFlutterUser.m b/ios/Classes/OSFlutterUser.m deleted file mode 100644 index 165b9ef8..00000000 --- a/ios/Classes/OSFlutterUser.m +++ /dev/null @@ -1,180 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#import "OSFlutterUser.h" -#import "OSFlutterCategories.h" -#import "OSFlutterPushSubscription.h" -#import -#import - -@implementation OSFlutterUser -+ (void)registerWithRegistrar:(NSObject *)registrar { - OSFlutterUser *instance = [OSFlutterUser new]; - - instance.channel = - [FlutterMethodChannel methodChannelWithName:@"OneSignal#user" - binaryMessenger:[registrar messenger]]; - - [registrar addMethodCallDelegate:instance channel:instance.channel]; - [OSFlutterPushSubscription registerWithRegistrar:registrar]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call - result:(FlutterResult)result { - if ([@"OneSignal#setLanguage" isEqualToString:call.method]) - [self setLanguage:call withResult:result]; - else if ([@"OneSignal#getOnesignalId" isEqualToString:call.method]) - [self getOnesignalId:call withResult:result]; - else if ([@"OneSignal#getExternalId" isEqualToString:call.method]) - [self getExternalId:call withResult:result]; - else if ([@"OneSignal#addAliases" isEqualToString:call.method]) - [self addAliases:call withResult:result]; - else if ([@"OneSignal#removeAliases" isEqualToString:call.method]) - [self removeAliases:call withResult:result]; - else if ([@"OneSignal#addTags" isEqualToString:call.method]) - [self addTags:call withResult:result]; - else if ([@"OneSignal#removeTags" isEqualToString:call.method]) - [self removeTags:call withResult:result]; - else if ([@"OneSignal#getTags" isEqualToString:call.method]) - [self getTags:call withResult:result]; - else if ([@"OneSignal#addEmail" isEqualToString:call.method]) - [self addEmail:call withResult:result]; - else if ([@"OneSignal#removeEmail" isEqualToString:call.method]) - [self removeEmail:call withResult:result]; - else if ([@"OneSignal#addSms" isEqualToString:call.method]) - [self addSms:call withResult:result]; - else if ([@"OneSignal#removeSms" isEqualToString:call.method]) - [self removeSms:call withResult:result]; - else if ([@"OneSignal#lifecycleInit" isEqualToString:call.method]) - [self lifecycleInit:call withResult:result]; - else - result(FlutterMethodNotImplemented); -} - -- (void)setLanguage:(FlutterMethodCall *)call withResult:(FlutterResult)result { - id language = call.arguments[@"language"]; - if (language == [NSNull null]) { - language = nil; - } - - [OneSignal.User setLanguage:language]; - result(nil); -} - -- (void)addAliases:(FlutterMethodCall *)call withResult:(FlutterResult)result { - NSDictionary *aliases = call.arguments; - [OneSignal.User addAliases:aliases]; - result(nil); -} - -- (void)removeAliases:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - NSDictionary *aliases = call.arguments; - [OneSignal.User removeAliases:aliases]; - result(nil); -} - -- (void)addTags:(FlutterMethodCall *)call withResult:(FlutterResult)result { - NSDictionary *tags = call.arguments; - [OneSignal.User addTags:tags]; - result(nil); -} - -- (void)removeTags:(FlutterMethodCall *)call withResult:(FlutterResult)result { - NSDictionary *tags = call.arguments; - [OneSignal.User removeTags:tags]; - result(nil); -} - -- (void)getTags:(FlutterMethodCall *)call withResult:(FlutterResult)result { - result([OneSignal.User getTags]); -} - -- (void)addEmail:(FlutterMethodCall *)call withResult:(FlutterResult)result { - NSString *email = call.arguments; - [OneSignal.User addEmail:email]; - result(nil); -} - -- (void)removeEmail:(FlutterMethodCall *)call withResult:(FlutterResult)result { - NSString *email = call.arguments; - [OneSignal.User removeEmail:email]; - result(nil); -} - -- (void)addSms:(FlutterMethodCall *)call withResult:(FlutterResult)result { - NSString *smsNumber = call.arguments; - [OneSignal.User addSms:smsNumber]; - result(nil); -} - -- (void)removeSms:(FlutterMethodCall *)call withResult:(FlutterResult)result { - NSString *smsNumber = call.arguments; - [OneSignal.User removeSms:smsNumber]; - result(nil); -} - -- (void)lifecycleInit:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - [OneSignal.User addObserver:self]; - result(nil); -} - -- (void)onUserStateDidChangeWithState:(OSUserChangedState *)state { - NSString *onesignalId = [self getStringOrNSNull:state.current.onesignalId]; - NSString *externalId = [self getStringOrNSNull:state.current.externalId]; - - NSMutableDictionary *result = [NSMutableDictionary new]; - - NSMutableDictionary *currentObject = [NSMutableDictionary new]; - - currentObject[@"onesignalId"] = onesignalId; - currentObject[@"externalId"] = externalId; - result[@"current"] = currentObject; - - [self.channel invokeMethod:@"OneSignal#onUserStateChange" arguments:result]; -} - -- (void)getOnesignalId:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - result(OneSignal.User.onesignalId); -} - -- (void)getExternalId:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - result(OneSignal.User.externalId); -} - -/** Helper method to return NSNull if string is empty or nil **/ -- (NSString *)getStringOrNSNull:(NSString *)string { - // length method can be used on nil and strings - if (string.length > 0) { - return string; - } else { - return [NSNull null]; - } -} -@end diff --git a/ios/Classes/OneSignalPlugin.h b/ios/Classes/OneSignalPlugin.h deleted file mode 100644 index 5b3fcb1e..00000000 --- a/ios/Classes/OneSignalPlugin.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import -#import - -@interface OneSignalPlugin : NSObject - -// Do NOT initialize instances of this class. -// You must only reference the shared instance. -+ (instancetype)sharedInstance; -@end diff --git a/ios/Classes/OneSignalPlugin.m b/ios/Classes/OneSignalPlugin.m deleted file mode 100644 index 9309a8b7..00000000 --- a/ios/Classes/OneSignalPlugin.m +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Modified MIT License - * - * Copyright 2023 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in - * connection with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#import "OneSignalPlugin.h" -#import "OSFlutterCategories.h" -#import "OSFlutterDebug.h" -#import "OSFlutterInAppMessages.h" -#import "OSFlutterLiveActivities.h" -#import "OSFlutterLocation.h" -#import "OSFlutterNotifications.h" -#import "OSFlutterSession.h" -#import "OSFlutterUser.h" - -@interface OneSignalPlugin () - -@property(strong, nonatomic) FlutterMethodChannel *channel; - -@end - -@implementation OneSignalPlugin - -+ (instancetype)sharedInstance { - static OneSignalPlugin *sharedInstance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedInstance = [OneSignalPlugin new]; - }); - return sharedInstance; -} - -#pragma mark FlutterPlugin -+ (void)registerWithRegistrar:(NSObject *)registrar { - - OneSignalWrapper.sdkType = @"flutter"; - OneSignalWrapper.sdkVersion = @"050305"; - [OneSignal initialize:nil withLaunchOptions:nil]; - - OneSignalPlugin.sharedInstance.channel = - [FlutterMethodChannel methodChannelWithName:@"OneSignal" - binaryMessenger:[registrar messenger]]; - - [registrar addMethodCallDelegate:OneSignalPlugin.sharedInstance - channel:OneSignalPlugin.sharedInstance.channel]; - [OSFlutterDebug registerWithRegistrar:registrar]; - [OSFlutterUser registerWithRegistrar:registrar]; - [OSFlutterNotifications registerWithRegistrar:registrar]; - [OSFlutterSession registerWithRegistrar:registrar]; - [OSFlutterLocation registerWithRegistrar:registrar]; - [OSFlutterInAppMessages registerWithRegistrar:registrar]; - [OSFlutterLiveActivities registerWithRegistrar:registrar]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call - result:(FlutterResult)result { - if ([@"OneSignal#initialize" isEqualToString:call.method]) - [self initialize:call withResult:result]; - else if ([@"OneSignal#login" isEqualToString:call.method]) - [self login:call withResult:result]; - else if ([@"OneSignal#logout" isEqualToString:call.method]) - [self logout:call withResult:result]; - else if ([@"OneSignal#consentRequired" isEqualToString:call.method]) - [self setConsentRequired:call withResult:result]; - else if ([@"OneSignal#consentGiven" isEqualToString:call.method]) - [self setConsentGiven:call withResult:result]; - else - result(FlutterMethodNotImplemented); -} - -#pragma mark Init - -- (void)initialize:(FlutterMethodCall *)call withResult:(FlutterResult)result { - [OneSignal initialize:call.arguments[@"appId"] withLaunchOptions:nil]; - result(nil); -} - -#pragma mark Login Logout - -- (void)login:(FlutterMethodCall *)call withResult:(FlutterResult)result { - [OneSignal login:call.arguments[@"externalId"]]; - result(nil); -} - -- (void)logout:(FlutterMethodCall *)call withResult:(FlutterResult)result { - [OneSignal logout]; - result(nil); -} - -#pragma mark Privacy Consent - -- (void)setConsentGiven:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - BOOL granted = [call.arguments[@"granted"] boolValue]; - [OneSignal setConsentGiven:granted]; - result(nil); -} - -- (void)setConsentRequired:(FlutterMethodCall *)call - withResult:(FlutterResult)result { - BOOL required = [call.arguments[@"required"] boolValue]; - [OneSignal setConsentRequired:required]; - result(nil); -} - -@end From 3fc7238e3ff5ccea4851f2940769108e188301de Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 7 Jan 2026 14:55:51 -0800 Subject: [PATCH 7/8] more tweaks --- example_spm/ios/Flutter/Flutter.podspec | 18 ------------------ .../ios/Runner.xcodeproj/project.pbxproj | 12 ++---------- .../contents.xcworkspacedata | 3 --- 3 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 example_spm/ios/Flutter/Flutter.podspec diff --git a/example_spm/ios/Flutter/Flutter.podspec b/example_spm/ios/Flutter/Flutter.podspec deleted file mode 100644 index 3aed58d3..00000000 --- a/example_spm/ios/Flutter/Flutter.podspec +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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| - s.name = 'Flutter' - s.version = '1.0.0' - s.summary = 'A UI toolkit for beautiful and fast apps.' - s.homepage = 'https://flutter.dev' - 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 = '13.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' -end diff --git a/example_spm/ios/Runner.xcodeproj/project.pbxproj b/example_spm/ios/Runner.xcodeproj/project.pbxproj index 4656ecdd..90975f13 100644 --- a/example_spm/ios/Runner.xcodeproj/project.pbxproj +++ b/example_spm/ios/Runner.xcodeproj/project.pbxproj @@ -169,7 +169,6 @@ 47CD9D282BE10D9400F8B006 /* ExampleWidget */, 97C146EF1CF9000F007C117D /* Products */, E458450F0521E6D94C4900F1 /* Frameworks */, - BA809C1A17A51DB9BC859D35 /* Pods */, ); sourceTree = ""; }; @@ -208,13 +207,6 @@ name = "Supporting Files"; sourceTree = ""; }; - BA809C1A17A51DB9BC859D35 /* Pods */ = { - isa = PBXGroup; - children = ( - ); - path = Pods; - sourceTree = ""; - }; CAB34E9020F96BDA0024CA6B /* OneSignalNotificationServiceExtension */ = { isa = PBXGroup; children = ( @@ -349,7 +341,7 @@ ); mainGroup = 97C146E51CF9000F007C117D; packageReferences = ( - 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */, + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */, ); productRefGroup = 97C146EF1CF9000F007C117D /* Products */; projectDirPath = ""; @@ -844,7 +836,7 @@ /* End XCConfigurationList section */ /* Begin XCLocalSwiftPackageReference section */ - 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = { + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = { isa = XCLocalSwiftPackageReference; relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; }; diff --git a/example_spm/ios/Runner.xcworkspace/contents.xcworkspacedata b/example_spm/ios/Runner.xcworkspace/contents.xcworkspacedata index 21a3cc14..1d526a16 100644 --- a/example_spm/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/example_spm/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,7 +4,4 @@ - - From 6f0580e70b45541d700474ebc3c7bb2296f0223d Mon Sep 17 00:00:00 2001 From: Fadi George Date: Wed, 7 Jan 2026 17:23:59 -0800 Subject: [PATCH 8/8] manually add one signal framework libs for NSE and widget --- example_spm/ios/ExampleWidget/Info.plist | 2 ++ .../ios/Runner.xcodeproj/project.pbxproj | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/example_spm/ios/ExampleWidget/Info.plist b/example_spm/ios/ExampleWidget/Info.plist index 0f118fb7..04f07b5f 100644 --- a/example_spm/ios/ExampleWidget/Info.plist +++ b/example_spm/ios/ExampleWidget/Info.plist @@ -2,6 +2,8 @@ + NSSupportsLiveActivities + NSExtension NSExtensionPointIdentifier diff --git a/example_spm/ios/Runner.xcodeproj/project.pbxproj b/example_spm/ios/Runner.xcodeproj/project.pbxproj index 90975f13..959021e9 100644 --- a/example_spm/ios/Runner.xcodeproj/project.pbxproj +++ b/example_spm/ios/Runner.xcodeproj/project.pbxproj @@ -28,6 +28,8 @@ CA2C87F221015A8D00D5D35D /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA2C87F121015A8C00D5D35D /* UserNotifications.framework */; }; CAB34E9320F96BDA0024CA6B /* NotificationService.m in Sources */ = {isa = PBXBuildFile; fileRef = CAB34E9220F96BDA0024CA6B /* NotificationService.m */; }; CAB34E9D20F96F460024CA6B /* OneSignalNotificationServiceExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = CAB34E8F20F96BDA0024CA6B /* OneSignalNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + E82451E52F0F38F80032825E /* OneSignalFramework in Frameworks */ = {isa = PBXBuildFile; productRef = E82451E42F0F38F80032825E /* OneSignalFramework */; }; + E82451E72F0F39250032825E /* OneSignalFramework in Frameworks */ = {isa = PBXBuildFile; productRef = E82451E62F0F39250032825E /* OneSignalFramework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -112,6 +114,7 @@ buildActionMask = 2147483647; files = ( 47CD9D272BE10D9400F8B006 /* SwiftUI.framework in Frameworks */, + E82451E72F0F39250032825E /* OneSignalFramework in Frameworks */, 47CD9D252BE10D9400F8B006 /* WidgetKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -128,6 +131,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + E82451E52F0F38F80032825E /* OneSignalFramework in Frameworks */, CA2C87F221015A8D00D5D35D /* UserNotifications.framework in Frameworks */, CA2C87DC21014E1C00D5D35D /* UIKit.framework in Frameworks */, CA2C87DA21014E1800D5D35D /* SystemConfiguration.framework in Frameworks */, @@ -342,6 +346,7 @@ mainGroup = 97C146E51CF9000F007C117D; packageReferences = ( 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */, + E82451E32F0F38D40032825E /* XCRemoteSwiftPackageReference "OneSignal-XCFramework" */, ); productRefGroup = 97C146EF1CF9000F007C117D /* Products */; projectDirPath = ""; @@ -842,11 +847,32 @@ }; /* End XCLocalSwiftPackageReference section */ +/* Begin XCRemoteSwiftPackageReference section */ + E82451E32F0F38D40032825E /* XCRemoteSwiftPackageReference "OneSignal-XCFramework" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/OneSignal/OneSignal-XCFramework"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.2.15; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + /* Begin XCSwiftPackageProductDependency section */ 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { isa = XCSwiftPackageProductDependency; productName = FlutterGeneratedPluginSwiftPackage; }; + E82451E42F0F38F80032825E /* OneSignalFramework */ = { + isa = XCSwiftPackageProductDependency; + package = E82451E32F0F38D40032825E /* XCRemoteSwiftPackageReference "OneSignal-XCFramework" */; + productName = OneSignalFramework; + }; + E82451E62F0F39250032825E /* OneSignalFramework */ = { + isa = XCSwiftPackageProductDependency; + package = E82451E32F0F38D40032825E /* XCRemoteSwiftPackageReference "OneSignal-XCFramework" */; + productName = OneSignalFramework; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */;