diff --git a/flutter_local_notifications/CHANGELOG.md b/flutter_local_notifications/CHANGELOG.md index b10015f0a..160e1c52d 100644 --- a/flutter_local_notifications/CHANGELOG.md +++ b/flutter_local_notifications/CHANGELOG.md @@ -1,3 +1,8 @@ +## [19.0.0-dev.3] + +* [iOS][macOS] **Breaking changes** the `DarwinNotificationActionOption` and `DarwinNotificationCategoryOption` are now enhanced enums with values accessible through the `value` property that are exactly the same as their native representations. Previously a bitwise left shift operation was applied to the index value +* [iOS][macOS] added Swift Package Manager support + ## [19.0.0-dev.2] * [Windows] Fixed an issue that happens with MSIX app builds. Thanks to PR from [Levi Lesches](https://github.com/Levi-Lesches) diff --git a/flutter_local_notifications/ios/Assets/.gitkeep b/flutter_local_notifications/ios/Assets/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/flutter_local_notifications/ios/Classes/Converters.h b/flutter_local_notifications/ios/Classes/Converters.h deleted file mode 120000 index a5ec78456..000000000 --- a/flutter_local_notifications/ios/Classes/Converters.h +++ /dev/null @@ -1 +0,0 @@ -../../darwin/Classes/Converters.h \ No newline at end of file diff --git a/flutter_local_notifications/ios/Classes/Converters.m b/flutter_local_notifications/ios/Classes/Converters.m deleted file mode 120000 index 2b80053dc..000000000 --- a/flutter_local_notifications/ios/Classes/Converters.m +++ /dev/null @@ -1 +0,0 @@ -../../darwin/Classes/Converters.m \ No newline at end of file diff --git a/flutter_local_notifications/ios/flutter_local_notifications.podspec b/flutter_local_notifications/ios/flutter_local_notifications.podspec index 1da6572b9..e5a7f3646 100644 --- a/flutter_local_notifications/ios/flutter_local_notifications.podspec +++ b/flutter_local_notifications/ios/flutter_local_notifications.podspec @@ -10,12 +10,12 @@ Flutter plugin for displaying local notifications. DESC s.homepage = 'https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications' s.license = { :type => 'BSD', :file => '../LICENSE' } - s.author = { 'Michael Bui' => 'michael@dexterx.dev' } + s.author = { 'Michael Bui' => 'borromini_eeckhout@simplelogin.com' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.public_header_files = 'Classes/**/*.h' + s.source_files = 'flutter_local_notifications/Sources/flutter_local_notifications/**/*.{h,m}' + s.public_header_files = 'flutter_local_notifications/Sources/flutter_local_notifications/include/**/*.h' s.dependency 'Flutter' - s.resource_bundles = {'flutter_local_notifications_privacy' => ['Resources/PrivacyInfo.xcprivacy']} + s.resource_bundles = {'flutter_local_notifications_privacy' => ['flutter_local_notifications/Sources/flutter_local_notifications/PrivacyInfo.xcprivacy']} s.ios.deployment_target = '11.0' end diff --git a/flutter_local_notifications/ios/flutter_local_notifications/Package.swift b/flutter_local_notifications/ios/flutter_local_notifications/Package.swift new file mode 100644 index 000000000..20e491f05 --- /dev/null +++ b/flutter_local_notifications/ios/flutter_local_notifications/Package.swift @@ -0,0 +1,27 @@ +// 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: "flutter_local_notifications", + platforms: [ + .iOS("11.0") + ], + products: [ + .library(name: "flutter-local-notifications", targets: ["flutter_local_notifications"]) + ], + dependencies: [], + targets: [ + .target( + name: "flutter_local_notifications", + dependencies: [], + resources: [ + .process("PrivacyInfo.xcprivacy") + ], + cSettings: [ + .headerSearchPath("include/flutter_local_notifications") + ] + ) + ] +) diff --git a/flutter_local_notifications/ios/Classes/ActionEventSink.m b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/ActionEventSink.m similarity index 93% rename from flutter_local_notifications/ios/Classes/ActionEventSink.m rename to flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/ActionEventSink.m index 228bb32d3..5c3d51d88 100644 --- a/flutter_local_notifications/ios/Classes/ActionEventSink.m +++ b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/ActionEventSink.m @@ -5,7 +5,7 @@ // Created by Sebastian Roth on 11/1/20. // -#import "ActionEventSink.h" +#import "./include/flutter_local_notifications/ActionEventSink.h" @interface ActionEventSink () { NSMutableArray *cache; diff --git a/flutter_local_notifications/darwin/Classes/Converters.m b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/Converters.m similarity index 100% rename from flutter_local_notifications/darwin/Classes/Converters.m rename to flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/Converters.m diff --git a/flutter_local_notifications/ios/Classes/FlutterEngineManager.m b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/FlutterEngineManager.m similarity index 94% rename from flutter_local_notifications/ios/Classes/FlutterEngineManager.m rename to flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/FlutterEngineManager.m index 0c917bc28..4c3ad349b 100644 --- a/flutter_local_notifications/ios/Classes/FlutterEngineManager.m +++ b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/FlutterEngineManager.m @@ -9,8 +9,8 @@ #import -#import "ActionEventSink.h" -#import "FlutterEngineManager.h" +#import "./include/flutter_local_notifications/ActionEventSink.h" +#import "./include/flutter_local_notifications/FlutterEngineManager.h" NS_ASSUME_NONNULL_BEGIN diff --git a/flutter_local_notifications/ios/Classes/FlutterLocalNotificationsPlugin.m b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/FlutterLocalNotificationsPlugin.m similarity index 99% rename from flutter_local_notifications/ios/Classes/FlutterLocalNotificationsPlugin.m rename to flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/FlutterLocalNotificationsPlugin.m index 2f6aabadc..66055a4d8 100644 --- a/flutter_local_notifications/ios/Classes/FlutterLocalNotificationsPlugin.m +++ b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/FlutterLocalNotificationsPlugin.m @@ -1,7 +1,7 @@ -#import "FlutterLocalNotificationsPlugin.h" -#import "ActionEventSink.h" -#import "Converters.h" -#import "FlutterEngineManager.h" +#import "./include/flutter_local_notifications/FlutterLocalNotificationsPlugin.h" +#import "./include/flutter_local_notifications/ActionEventSink.h" +#import "./include/flutter_local_notifications/Converters.h" +#import "./include/flutter_local_notifications/FlutterEngineManager.h" @implementation FlutterLocalNotificationsPlugin { FlutterMethodChannel *_channel; diff --git a/flutter_local_notifications/ios/Resources/PrivacyInfo.xcprivacy b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/PrivacyInfo.xcprivacy similarity index 100% rename from flutter_local_notifications/ios/Resources/PrivacyInfo.xcprivacy rename to flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/PrivacyInfo.xcprivacy diff --git a/flutter_local_notifications/ios/Classes/ActionEventSink.h b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/include/flutter_local_notifications/ActionEventSink.h similarity index 100% rename from flutter_local_notifications/ios/Classes/ActionEventSink.h rename to flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/include/flutter_local_notifications/ActionEventSink.h diff --git a/flutter_local_notifications/darwin/Classes/Converters.h b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/include/flutter_local_notifications/Converters.h similarity index 100% rename from flutter_local_notifications/darwin/Classes/Converters.h rename to flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/include/flutter_local_notifications/Converters.h diff --git a/flutter_local_notifications/ios/Classes/FlutterEngineManager.h b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/include/flutter_local_notifications/FlutterEngineManager.h similarity index 100% rename from flutter_local_notifications/ios/Classes/FlutterEngineManager.h rename to flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/include/flutter_local_notifications/FlutterEngineManager.h diff --git a/flutter_local_notifications/ios/Classes/FlutterLocalNotificationsPlugin.h b/flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/include/flutter_local_notifications/FlutterLocalNotificationsPlugin.h similarity index 100% rename from flutter_local_notifications/ios/Classes/FlutterLocalNotificationsPlugin.h rename to flutter_local_notifications/ios/flutter_local_notifications/Sources/flutter_local_notifications/include/flutter_local_notifications/FlutterLocalNotificationsPlugin.h diff --git a/flutter_local_notifications/lib/src/platform_specifics/darwin/mappers.dart b/flutter_local_notifications/lib/src/platform_specifics/darwin/mappers.dart index 06610ff0f..1a4d9e7fb 100644 --- a/flutter_local_notifications/lib/src/platform_specifics/darwin/mappers.dart +++ b/flutter_local_notifications/lib/src/platform_specifics/darwin/mappers.dart @@ -11,7 +11,7 @@ extension DarwinNotificationActionMapper on DarwinNotificationAction { 'identifier': identifier, 'title': title, 'options': options - .map((e) => 1 << e.index) // ignore: always_specify_types + .map((e) => e.value) // ignore: always_specify_types .toList(), 'type': type.name, if (buttonTitle != null) 'buttonTitle': buttonTitle!, @@ -26,7 +26,7 @@ extension DarwinNotificationCategoryMapper on DarwinNotificationCategory { .map((e) => e.toMap()) // ignore: always_specify_types .toList(), 'options': options - .map((e) => 1 << e.index) // ignore: always_specify_types + .map((e) => e.value) // ignore: always_specify_types .toList(), }; } diff --git a/flutter_local_notifications/lib/src/platform_specifics/darwin/notification_action_option.dart b/flutter_local_notifications/lib/src/platform_specifics/darwin/notification_action_option.dart index 752cde7c3..51bc158ea 100644 --- a/flutter_local_notifications/lib/src/platform_specifics/darwin/notification_action_option.dart +++ b/flutter_local_notifications/lib/src/platform_specifics/darwin/notification_action_option.dart @@ -7,16 +7,22 @@ enum DarwinNotificationActionOption { /// The action can be performed only on an unlocked device. /// /// Corresponds to [`UNNotificationActionOptions.authenticationRequired`](https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/1648196-authenticationrequired). - authenticationRequired, + authenticationRequired(1 << 0), /// The action performs a destructive task. /// /// Corresponds to [`UNNotificationActionOptions.destructive`](https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/1648199-destructive) - destructive, + destructive(1 << 1), /// The action causes the app to launch in the foreground. /// /// Corresponds to [`UNNotificationActionOptions.foreground`](https://developer.apple.com/documentation/usernotifications/unnotificationactionoptions/1648192-foreground) - foreground, + foreground(1 << 2); + + /// Constructs an instance of [DarwinNotificationActionOption]. + const DarwinNotificationActionOption(this.value); + + /// The integer representation of [DarwinNotificationActionOption]. + final int value; } diff --git a/flutter_local_notifications/lib/src/platform_specifics/darwin/notification_category_option.dart b/flutter_local_notifications/lib/src/platform_specifics/darwin/notification_category_option.dart index 95d8e713e..eeb535477 100644 --- a/flutter_local_notifications/lib/src/platform_specifics/darwin/notification_category_option.dart +++ b/flutter_local_notifications/lib/src/platform_specifics/darwin/notification_category_option.dart @@ -7,28 +7,34 @@ enum DarwinNotificationCategoryOption { /// handling. /// /// Corresponds to [`UNNotificationCategoryOptions.customDismissAction`](https://developer.apple.com/documentation/usernotifications/unnotificationcategoryoptions/1649280-customdismissaction). - customDismissAction, + customDismissAction(1 << 0), /// Allow CarPlay to display notifications of this type. /// /// Corresponds to [`UNNotificationCategoryOptions.allowInCarPlay`](https://developer.apple.com/documentation/usernotifications/unnotificationcategoryoptions/1649281-allowincarplay). - allowInCarPlay, + allowInCarPlay(1 << 1), /// Show the notification's title, even if the user has disabled notification /// previews for the app. /// /// Corresponds to [`UNNotificationCategoryOptions.hiddenPreviewShowTitle`](https://developer.apple.com/documentation/usernotifications/unnotificationcategoryoptions/2873735-hiddenpreviewsshowtitle). - hiddenPreviewShowTitle, + hiddenPreviewShowTitle(1 << 2), /// Show the notification's subtitle, even if the user has disabled /// notification previews for the app. /// /// Corresponds to [`UNNotificationCategoryOptions.hiddenPreviewShowSubtitle`](https://developer.apple.com/documentation/usernotifications/unnotificationcategoryoptions/2873734-hiddenpreviewsshowsubtitle). - hiddenPreviewShowSubtitle, + hiddenPreviewShowSubtitle(1 << 3), /// An option that grants Siri permission to read incoming messages out loud /// when the user has a compatible audio output device connected. /// /// Corresponds to [`UNNotificationCategoryOptions.allowAnnouncement`](https://developer.apple.com/documentation/usernotifications/unnotificationcategoryoptions/3240647-allowannouncement). - allowAnnouncement, + allowAnnouncement(1 << 4); + + /// Constructs an instance of [DarwinNotificationCategoryOption]. + const DarwinNotificationCategoryOption(this.value); + + /// The integer representation of [DarwinNotificationCategoryOption]. + final int value; } diff --git a/flutter_local_notifications/macos/Classes/Converters.h b/flutter_local_notifications/macos/Classes/Converters.h deleted file mode 100644 index 732b24799..000000000 --- a/flutter_local_notifications/macos/Classes/Converters.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// Converters.h -// flutter_local_notifications -// - -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface Converters : NSObject - -+ (UNNotificationCategoryOptions)parseNotificationCategoryOptions: - (NSArray *)options API_AVAILABLE(ios(10.0), macos(10.14)); -+ (UNNotificationActionOptions)parseNotificationActionOptions:(NSArray *)options - API_AVAILABLE(ios(10.0), macos(10.14)); - -@end - -NS_ASSUME_NONNULL_END diff --git a/flutter_local_notifications/macos/Classes/Converters.m b/flutter_local_notifications/macos/Classes/Converters.m deleted file mode 120000 index 2b80053dc..000000000 --- a/flutter_local_notifications/macos/Classes/Converters.m +++ /dev/null @@ -1 +0,0 @@ -../../darwin/Classes/Converters.m \ No newline at end of file diff --git a/flutter_local_notifications/macos/flutter_local_notifications.podspec b/flutter_local_notifications/macos/flutter_local_notifications.podspec index e92e0212c..08b21cb46 100644 --- a/flutter_local_notifications/macos/flutter_local_notifications.podspec +++ b/flutter_local_notifications/macos/flutter_local_notifications.podspec @@ -11,13 +11,13 @@ Flutter plugin for displaying local notifications. DESC s.homepage = 'https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications' s.license = { :type => 'BSD', :file => '../LICENSE' } - s.author = { 'Michael Bui' => 'michael@dexterx.dev' } + s.author = { 'Michael Bui' => 'borromini_eeckhout@simplelogin.com' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*' + s.source_files = 'flutter_local_notifications/Sources/flutter_local_notifications/**/*.swift' s.dependency 'FlutterMacOS' s.platform = :osx, '10.14' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } - s.resource_bundles = {'flutter_local_notifications_privacy' => ['Resources/PrivacyInfo.xcprivacy']} + s.resource_bundles = {'flutter_local_notifications_privacy' => ['flutter_local_notifications/Sources/flutter_local_notifications/PrivacyInfo.xcprivacy']} s.swift_version = '5.0' end diff --git a/flutter_local_notifications/macos/flutter_local_notifications/Package.swift b/flutter_local_notifications/macos/flutter_local_notifications/Package.swift new file mode 100644 index 000000000..6784c790a --- /dev/null +++ b/flutter_local_notifications/macos/flutter_local_notifications/Package.swift @@ -0,0 +1,27 @@ +// 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: "flutter_local_notifications", + platforms: [ + .macOS("10.14") + ], + products: [ + .library(name: "flutter-local-notifications", targets: ["flutter_local_notifications"]) + ], + dependencies: [], + targets: [ + .target( + name: "flutter_local_notifications", + dependencies: [], + resources: [ + .process("PrivacyInfo.xcprivacy") + ], + cSettings: [ + .headerSearchPath("include/flutter_local_notifications") + ] + ) + ] +) diff --git a/flutter_local_notifications/macos/flutter_local_notifications/Sources/flutter_local_notifications/Converters.swift b/flutter_local_notifications/macos/flutter_local_notifications/Sources/flutter_local_notifications/Converters.swift new file mode 100644 index 000000000..b7497827e --- /dev/null +++ b/flutter_local_notifications/macos/flutter_local_notifications/Sources/flutter_local_notifications/Converters.swift @@ -0,0 +1,29 @@ +import UserNotifications + +public class Converters { + public static func parseNotificationCategoryOptions(_ options: [Any]?) -> UNNotificationCategoryOptions { + var result: UInt = 0 + + for option in options ?? [] { + guard let option = option as? NSNumber else { + continue + } + result |= option.uintValue + } + + return UNNotificationCategoryOptions(rawValue: result) + } + + public static func parseNotificationActionOptions(_ options: [Any]?) -> UNNotificationActionOptions { + var result: UInt = 0 + + for option in options ?? [] { + guard let option = option as? NSNumber else { + continue + } + result |= option.uintValue + } + + return UNNotificationActionOptions(rawValue: result) + } +} diff --git a/flutter_local_notifications/macos/Classes/FlutterLocalNotificationsPlugin.swift b/flutter_local_notifications/macos/flutter_local_notifications/Sources/flutter_local_notifications/FlutterLocalNotificationsPlugin.swift similarity index 100% rename from flutter_local_notifications/macos/Classes/FlutterLocalNotificationsPlugin.swift rename to flutter_local_notifications/macos/flutter_local_notifications/Sources/flutter_local_notifications/FlutterLocalNotificationsPlugin.swift diff --git a/flutter_local_notifications/macos/Resources/PrivacyInfo.xcprivacy b/flutter_local_notifications/macos/flutter_local_notifications/Sources/flutter_local_notifications/PrivacyInfo.xcprivacy similarity index 100% rename from flutter_local_notifications/macos/Resources/PrivacyInfo.xcprivacy rename to flutter_local_notifications/macos/flutter_local_notifications/Sources/flutter_local_notifications/PrivacyInfo.xcprivacy diff --git a/flutter_local_notifications/pubspec.yaml b/flutter_local_notifications/pubspec.yaml index 319c6c84c..ef112b444 100644 --- a/flutter_local_notifications/pubspec.yaml +++ b/flutter_local_notifications/pubspec.yaml @@ -2,7 +2,7 @@ name: flutter_local_notifications description: A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform. -version: 19.0.0-dev.2 +version: 19.0.0-dev.3 homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications issue_tracker: https://github.com/MaikuB/flutter_local_notifications/issues