未验证 提交 03e773a9 编写于 作者: C Chinmay Garde 提交者: GitHub

Guard availability of user notification related methods to iOS 10.0 (#12084)

* `NS_AVAILABLE_IOS(10_0)` makes us tell our compiler that the method needs
  to be stamped into the TU but we promise to do stuff in it only on iOS 10.0
  and above.
* `@availability` ensures that if those methods are called on iOS versions less
  than 10.0, we will do nothing with it. This guards us against the case where
  iOS introduced the functionality privately in older versions of iOS.
上级 9c00c26c
......@@ -83,11 +83,14 @@ static NSString* kBackgroundFetchCapatibility = @"fetch";
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:
(void (^)(UNNotificationPresentationOptions options))completionHandler {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
(void (^)(UNNotificationPresentationOptions options))completionHandler
NS_AVAILABLE_IOS(10_0) {
if (@available(iOS 10.0, *)) {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
}
}
}
......@@ -96,11 +99,13 @@ static NSString* kBackgroundFetchCapatibility = @"fetch";
*/
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
didReceiveNotificationResponse:(UNNotificationResponse*)response
withCompletionHandler:(void (^)(void))completionHandler {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
withCompletionHandler:(void (^)(void))completionHandler NS_AVAILABLE_IOS(10_0) {
if (@available(iOS 10.0, *)) {
if ([_lifeCycleDelegate respondsToSelector:_cmd]) {
[_lifeCycleDelegate userNotificationCenter:center
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}
}
}
......
......@@ -275,24 +275,29 @@ static BOOL isPowerOfTwo(NSUInteger x) {
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:
(void (^)(UNNotificationPresentationOptions options))completionHandler {
for (NSObject<FlutterApplicationLifeCycleDelegate>* delegate in _delegates) {
if ([delegate respondsToSelector:_cmd]) {
[delegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
(void (^)(UNNotificationPresentationOptions options))completionHandler
NS_AVAILABLE_IOS(10_0) {
if (@available(iOS 10.0, *)) {
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];
withCompletionHandler:(void (^)(void))completionHandler NS_AVAILABLE_IOS(10_0) {
if (@available(iOS 10.0, *)) {
for (id<FlutterApplicationLifeCycleDelegate> delegate in _delegates) {
if ([delegate respondsToSelector:_cmd]) {
[delegate userNotificationCenter:center
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册