Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d48d4a2
Add other UNUserNotificationDelegate method and register as delegate
bparrishMines Jul 16, 2019
a42883a
Add UNUserNotificationDelegate to receive delegate calls
bparrishMines Jul 17, 2019
a5a3ac3
format FlutterAppDelegate.h
bparrishMines Jul 17, 2019
151293c
format FlutterPlugin.h
bparrishMines Jul 17, 2019
ccc9b64
format FormatAppDelegate.mm
bparrishMines Jul 17, 2019
e6f6b57
format FlutterPluginAppLifeCycleDelegate.mm
bparrishMines Jul 17, 2019
6af5edd
Formatting
bparrishMines Jul 19, 2019
5e1c0c8
Merge branch 'master' into notifications
bparrishMines Jul 19, 2019
bd8ea05
Ad if statement in FlutterAppDelegate
bparrishMines Aug 12, 2019
e33de17
Use __IPHONE_OS_VERSION_MAX_ALLOWED instead
bparrishMines Aug 12, 2019
e2b0ab8
Guard only a single line
bparrishMines Aug 13, 2019
abd3bc6
Merge branch 'master' of github.com:flutter/engine into notifications
bparrishMines Aug 13, 2019
c6c2eea
Keep availability checks in headers
bparrishMines Aug 13, 2019
5618d26
Remove check of UNUserNotificationCenter
bparrishMines Aug 13, 2019
7d82637
Move UNUserNotificationCenterDelegate to FlutterApplicationLifeCycleD…
bparrishMines Aug 13, 2019
204d8b1
Make FlutterAppLifeCycleProvider conform to UNUserNotificationCenterD…
bparrishMines Aug 20, 2019
168c674
Add single quotes
bparrishMines Aug 20, 2019
8e0def6
Formatting
bparrishMines Aug 20, 2019
2501158
Remove delegate methods and use protocol in FlutterPlugin.h
bparrishMines Aug 22, 2019
8875d35
Update FlutterPluginAppLifeCycleDelegate.h
bparrishMines Aug 22, 2019
108155f
Merge branch 'master' of github.com:flutter/engine into notifications
bparrishMines Aug 22, 2019
fb05b3a
Formatting
bparrishMines Aug 22, 2019
4ab5307
If Statement formatting
bparrishMines Aug 22, 2019
d4415f4
Formatting
bparrishMines Aug 29, 2019
1002702
Add respondsToSelector to optional methods
bparrishMines Sep 5, 2019
e9f5d00
Merge branch 'notifications' of github.com:bparrishMines/engine into …
bparrishMines Sep 5, 2019
3e299e4
Square brackets
bparrishMines Sep 5, 2019
5a84f3d
Merge branch 'master' of github.com:flutter/engine into notifications
bparrishMines Sep 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ NS_ASSUME_NONNULL_BEGIN
* Protocol for listener of events from the UIApplication, typically a FlutterPlugin.
*/
@protocol FlutterApplicationLifeCycleDelegate
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
<UNUserNotificationCenterDelegate>
#endif
@optional
/**
* Called if this has been registered for `UIApplicationDelegate` callbacks.
Expand Down Expand Up @@ -98,15 +101,6 @@ NS_ASSUME_NONNULL_BEGIN
"See -[UIApplicationDelegate application:didReceiveLocalNotification:] deprecation",
ios(4.0, 10.0));

/**
* Calls all plugins registered for `UNUserNotificationCenterDelegate` callbacks.
*/
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:
(void (^)(UNNotificationPresentationOptions options))completionHandler
API_AVAILABLE(ios(10));

/**
* Called if this has been registered for `UIApplicationDelegate` callbacks.
*
Expand Down Expand Up @@ -372,8 +366,14 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
/***************************************************************************************************
* Implement this in the `UIAppDelegate` of your app to enable Flutter plugins to register
* themselves to the application life cycle events.
*
* For plugins to receive events from `UNUserNotificationCenter`, register this as the
* `UNUserNotificationCenterDelegate`.
*/
@protocol FlutterAppLifeCycleProvider
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
<UNUserNotificationCenterDelegate>
#endif
- (void)addApplicationLifeCycleDelegate:(NSObject<FlutterApplicationLifeCycleDelegate>*)delegate;
@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ NS_ASSUME_NONNULL_BEGIN
*/
FLUTTER_EXPORT
@interface FlutterPluginAppLifeCycleDelegate : NSObject
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
<UNUserNotificationCenterDelegate>
#endif

/**
* Registers `delegate` to receive life cycle callbacks via this FlutterPluginAppLifecycleDelegate
Expand Down Expand Up @@ -70,15 +73,6 @@ FLUTTER_EXPORT
"See -[UIApplicationDelegate application:didReceiveLocalNotification:] deprecation",
ios(4.0, 10.0));

/**
* Calls all plugins registered for `UNUserNotificationCenterDelegate` callbacks.
*/
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:
(void (^)(UNNotificationPresentationOptions options))completionHandler
API_AVAILABLE(ios(10));

/**
* Calls all plugins registered for `UIApplicationDelegate` callbacks in order of registration until
* some plugin handles the request.
Expand Down
18 changes: 15 additions & 3 deletions shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,27 @@ - (void)application:(UIApplication*)application
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:
(void (^)(UNNotificationPresentationOptions options))completionHandler
API_AVAILABLE(ios(10)) {
if (@available(iOS 10.0, *)) {
(void (^)(UNNotificationPresentationOptions options))completionHandler {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
}
}

/**
* Calls all plugins registered for `UNUserNotificationCenterDelegate` callbacks.
*/
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
didReceiveNotificationResponse:(UNNotificationResponse*)response
withCompletionHandler:(void (^)(void))completionHandler {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}
}

- (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,23 @@ - (void)userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:
(void (^)(UNNotificationPresentationOptions options))completionHandler {
if (@available(iOS 10.0, *)) {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if (!delegate) {
continue;
}
if ([delegate respondsToSelector:_cmd]) {
[delegate userNotificationCenter:center
willPresentNotification:notification
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if ([delegate respondsToSelector:_cmd]) {
[delegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
}
}
}

- (void)userNotificationCenter:(UNUserNotificationCenter*)center
didReceiveNotificationResponse:(UNNotificationResponse*)response
withCompletionHandler:(void (^)(void))completionHandler {
for (id<FlutterApplicationLifeCycleDelegate> delegate in _delegates) {
if ([delegate respondsToSelector:_cmd]) {
[delegate userNotificationCenter:center
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}
}
}
}
Expand Down