-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[flutter_local_notifications] Add CarPlay notification support with IOSInitializationSettings #2716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
derrik-fleming
wants to merge
1
commit into
MaikuB:master
Choose a base branch
from
Gentex-Corporation:feat/ios-carplay-notifications
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ @implementation FlutterLocalNotificationsPlugin { | |
| NSString *const REQUEST_PROVISIONAL_PERMISSION = | ||
| @"requestProvisionalPermission"; | ||
| NSString *const REQUEST_CRITICAL_PERMISSION = @"requestCriticalPermission"; | ||
| NSString *const REQUEST_CARPLAY_PERMISSION = @"requestCarPlayPermission"; | ||
| NSString *const REQUEST_PROVIDES_APP_NOTIFICATION_SETTINGS = | ||
| @"requestProvidesAppNotificationSettings"; | ||
| NSString *const DEFAULT_PRESENT_ALERT = @"defaultPresentAlert"; | ||
|
|
@@ -61,6 +62,7 @@ @implementation FlutterLocalNotificationsPlugin { | |
| NSString *const BADGE_PERMISSION = @"badge"; | ||
| NSString *const PROVISIONAL_PERMISSION = @"provisional"; | ||
| NSString *const CRITICAL_PERMISSION = @"critical"; | ||
| NSString *const CARPLAY_PERMISSION = @"carPlay"; | ||
| NSString *const PROVIDES_APP_NOTIFICATION_SETTINGS = | ||
| @"providesAppNotificationSettings"; | ||
| NSString *const CALLBACK_DISPATCHER = @"callbackDispatcher"; | ||
|
|
@@ -112,6 +114,7 @@ @implementation FlutterLocalNotificationsPlugin { | |
| NSString *const IS_CRITICAL_ENABLED = @"isCriticalEnabled"; | ||
| NSString *const IS_PROVIDES_APP_NOTIFICATION_SETTINGS_ENABLED = | ||
| @"isProvidesAppNotificationSettingsEnabled"; | ||
| NSString *const IS_CAR_PLAY_ENABLED = @"isCarPlayEnabled"; | ||
|
|
||
| NSString *const CRITICAL_SOUND_VOLUME = @"criticalSoundVolume"; | ||
|
|
||
|
|
@@ -353,6 +356,8 @@ - (void)initialize:(NSDictionary *_Nonnull)arguments | |
| bool requestedBadgePermission = false; | ||
| bool requestedProvisionalPermission = false; | ||
| bool requestedCriticalPermission = false; | ||
| bool requestedCarPlayPermission = false; | ||
| bool carPlayPermissionSpecified = false; | ||
| bool requestedProvidesAppNotificationSettings = false; | ||
| NSMutableDictionary *presentationOptions = [[NSMutableDictionary alloc] init]; | ||
| if ([self containsKey:DEFAULT_PRESENT_ALERT forDictionary:arguments]) { | ||
|
|
@@ -401,6 +406,11 @@ - (void)initialize:(NSDictionary *_Nonnull)arguments | |
| requestedCriticalPermission = | ||
| [arguments[REQUEST_CRITICAL_PERMISSION] boolValue]; | ||
| } | ||
| if ([self containsKey:REQUEST_CARPLAY_PERMISSION forDictionary:arguments]) { | ||
| carPlayPermissionSpecified = true; | ||
| requestedCarPlayPermission = | ||
| [arguments[REQUEST_CARPLAY_PERMISSION] boolValue]; | ||
| } | ||
| if ([self containsKey:REQUEST_PROVIDES_APP_NOTIFICATION_SETTINGS | ||
| forDictionary:arguments]) { | ||
| requestedProvidesAppNotificationSettings = | ||
|
|
@@ -426,6 +436,8 @@ - (void)initialize:(NSDictionary *_Nonnull)arguments | |
| requestedProvisionalPermission | ||
| criticalPermission: | ||
| requestedCriticalPermission | ||
| carPlayPermission:requestedCarPlayPermission | ||
| carPlayPermissionSpecified:carPlayPermissionSpecified | ||
| providesAppNotificationSettings: | ||
| requestedProvidesAppNotificationSettings | ||
| result:result]; | ||
|
|
@@ -440,6 +452,8 @@ - (void)requestPermissions:(NSDictionary *_Nonnull)arguments | |
| bool badgePermission = false; | ||
| bool provisionalPermission = false; | ||
| bool criticalPermission = false; | ||
| bool requestCarPlayPermission = false; | ||
| bool carPlayPermissionSpecified = false; | ||
| bool providesAppNotificationSettings = false; | ||
| if ([self containsKey:SOUND_PERMISSION forDictionary:arguments]) { | ||
| soundPermission = [arguments[SOUND_PERMISSION] boolValue]; | ||
|
|
@@ -456,6 +470,12 @@ - (void)requestPermissions:(NSDictionary *_Nonnull)arguments | |
| if ([self containsKey:CRITICAL_PERMISSION forDictionary:arguments]) { | ||
| criticalPermission = [arguments[CRITICAL_PERMISSION] boolValue]; | ||
| } | ||
| if ([self containsKey:CARPLAY_PERMISSION forDictionary:arguments]) { | ||
| carPlayPermissionSpecified = true; | ||
| requestCarPlayPermission = | ||
| [arguments[CARPLAY_PERMISSION] boolValue]; | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: remove blank line |
||
| } | ||
| if ([self containsKey:PROVIDES_APP_NOTIFICATION_SETTINGS | ||
| forDictionary:arguments]) { | ||
| providesAppNotificationSettings = | ||
|
|
@@ -466,6 +486,8 @@ - (void)requestPermissions:(NSDictionary *_Nonnull)arguments | |
| badgePermission:badgePermission | ||
| provisionalPermission:provisionalPermission | ||
| criticalPermission:criticalPermission | ||
| carPlayPermission:requestCarPlayPermission | ||
| carPlayPermissionSpecified:carPlayPermissionSpecified | ||
| providesAppNotificationSettings:providesAppNotificationSettings | ||
| result:result]; | ||
| } | ||
|
|
@@ -475,6 +497,8 @@ - (void)requestPermissionsImpl:(bool)soundPermission | |
| badgePermission:(bool)badgePermission | ||
| provisionalPermission:(bool)provisionalPermission | ||
| criticalPermission:(bool)criticalPermission | ||
| carPlayPermission:(bool)carPlayPermission | ||
| carPlayPermissionSpecified:(bool)carPlayPermissionSpecified | ||
| providesAppNotificationSettings:(bool)providesAppNotificationSettings | ||
| result:(FlutterResult _Nonnull)result { | ||
| if (!soundPermission && !alertPermission && !badgePermission && | ||
|
|
@@ -495,6 +519,11 @@ - (void)requestPermissionsImpl:(bool)soundPermission | |
| if (badgePermission) { | ||
| authorizationOptions += UNAuthorizationOptionBadge; | ||
| } | ||
| if (@available(iOS 10.0, *)) { | ||
| if (carPlayPermissionSpecified && carPlayPermission) { | ||
| authorizationOptions += UNAuthorizationOptionCarPlay; | ||
| } | ||
| } | ||
| if (@available(iOS 12.0, *)) { | ||
| if (provisionalPermission) { | ||
| authorizationOptions += UNAuthorizationOptionProvisional; | ||
|
|
@@ -530,6 +559,7 @@ - (void)checkPermissions:(NSDictionary *_Nonnull)arguments | |
| BOOL isProvisionalEnabled = false; | ||
| BOOL isCriticalEnabled = false; | ||
| BOOL isProvidesAppNotificationSettingsEnabled = false; | ||
| BOOL isCarPlayEnabled = false; | ||
|
|
||
| if (@available(iOS 12.0, *)) { | ||
| isProvisionalEnabled = | ||
|
|
@@ -540,6 +570,11 @@ - (void)checkPermissions:(NSDictionary *_Nonnull)arguments | |
| settings.providesAppNotificationSettings; | ||
| } | ||
|
|
||
| if (@available(iOS 10.0, *)) { | ||
| isCarPlayEnabled = | ||
| settings.carPlaySetting == UNNotificationSettingEnabled; | ||
| } | ||
|
|
||
| NSDictionary *dict = @{ | ||
| IS_NOTIFICATIONS_ENABLED : @(isEnabled), | ||
| IS_SOUND_ENABLED : @(isSoundEnabled), | ||
|
|
@@ -549,6 +584,7 @@ - (void)checkPermissions:(NSDictionary *_Nonnull)arguments | |
| IS_CRITICAL_ENABLED : @(isCriticalEnabled), | ||
| IS_PROVIDES_APP_NOTIFICATION_SETTINGS_ENABLED : | ||
| @(isProvidesAppNotificationSettingsEnabled), | ||
| IS_CAR_PLAY_ENABLED : @(isCarPlayEnabled), | ||
| }; | ||
|
|
||
| result(dict); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with rest of plugin docs that have been using "or newer"