mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Added delegate forwarding for didReceiveLocalNotification and willPresentNotification (flutter/engine#6858)
This commit is contained in:
parent
3ce4d16b63
commit
d4cedc97b4
@ -6,6 +6,7 @@
|
||||
#define FLUTTER_FLUTTERPLUGIN_H_
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <UserNotifications/UNUserNotificationCenter.h>
|
||||
|
||||
#include "FlutterBinaryMessenger.h"
|
||||
#include "FlutterChannels.h"
|
||||
@ -116,6 +117,21 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
didReceiveRemoteNotification:(NSDictionary*)userInfo
|
||||
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler;
|
||||
|
||||
/**
|
||||
* Calls all plugins registered for `UIApplicationDelegate` callbacks.
|
||||
*/
|
||||
- (void)application:(UIApplication*)application
|
||||
didReceiveLocalNotification:(UILocalNotification*)notification;
|
||||
|
||||
/**
|
||||
* 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 plugin has been registered for `UIApplicationDelegate` callbacks.
|
||||
*
|
||||
|
||||
@ -85,6 +85,21 @@ FLUTTER_EXPORT
|
||||
didReceiveRemoteNotification:(NSDictionary*)userInfo
|
||||
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler;
|
||||
|
||||
/**
|
||||
* Calls all plugins registered for `UIApplicationDelegate` callbacks.
|
||||
*/
|
||||
- (void)application:(UIApplication*)application
|
||||
didReceiveLocalNotification:(UILocalNotification*)notification;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@ -94,6 +94,23 @@
|
||||
fetchCompletionHandler:completionHandler];
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication*)application
|
||||
didReceiveLocalNotification:(UILocalNotification*)notification {
|
||||
[_lifeCycleDelegate application:application didReceiveLocalNotification:notification];
|
||||
}
|
||||
|
||||
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
|
||||
willPresentNotification:(UNNotification*)notification
|
||||
withCompletionHandler:
|
||||
(void (^)(UNNotificationPresentationOptions options))completionHandler
|
||||
API_AVAILABLE(ios(10)) {
|
||||
if (@available(iOS 10.0, *)) {
|
||||
[_lifeCycleDelegate userNotificationCenter:center
|
||||
willPresentNotification:notification
|
||||
withCompletionHandler:completionHandler];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication*)application
|
||||
openURL:(NSURL*)url
|
||||
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options {
|
||||
|
||||
@ -202,6 +202,36 @@ static BOOL isPowerOfTwo(NSUInteger x) {
|
||||
}
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication*)application
|
||||
didReceiveLocalNotification:(UILocalNotification*)notification {
|
||||
for (id<FlutterPlugin> plugin in _pluginDelegates) {
|
||||
if (!plugin) {
|
||||
continue;
|
||||
}
|
||||
if ([plugin respondsToSelector:_cmd]) {
|
||||
[plugin application:application didReceiveLocalNotification:notification];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
|
||||
willPresentNotification:(UNNotification*)notification
|
||||
withCompletionHandler:
|
||||
(void (^)(UNNotificationPresentationOptions options))completionHandler {
|
||||
if (@available(iOS 10.0, *)) {
|
||||
for (id<FlutterPlugin> plugin in _pluginDelegates) {
|
||||
if (!plugin) {
|
||||
continue;
|
||||
}
|
||||
if ([plugin respondsToSelector:_cmd]) {
|
||||
[plugin userNotificationCenter:center
|
||||
willPresentNotification:notification
|
||||
withCompletionHandler:completionHandler];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication*)application
|
||||
openURL:(NSURL*)url
|
||||
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user