[quick_actions] Fix UIApplicationShortcutItem availability and pod lint warnings (#2687)
diff --git a/packages/quick_actions/CHANGELOG.md b/packages/quick_actions/CHANGELOG.md
index af9b629..e086407 100644
--- a/packages/quick_actions/CHANGELOG.md
+++ b/packages/quick_actions/CHANGELOG.md
@@ -3,6 +3,8 @@
* Bump the minimum Flutter version to 1.12.13+hotfix.5.
* Clean up various Android workarounds no longer needed after framework v1.12.
* Complete v2 embedding support.
+* Fix UIApplicationShortcutItem availability warnings.
+* Fix CocoaPods podspec lint warnings.
## 0.4.0+3
diff --git a/packages/quick_actions/ios/Classes/FLTQuickActionsPlugin.m b/packages/quick_actions/ios/Classes/FLTQuickActionsPlugin.m
index a9bb33e..88ff739 100644
--- a/packages/quick_actions/ios/Classes/FLTQuickActionsPlugin.m
+++ b/packages/quick_actions/ios/Classes/FLTQuickActionsPlugin.m
@@ -22,45 +22,52 @@
}
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
- if ([call.method isEqualToString:@"setShortcutItems"]) {
- setShortcutItems(call.arguments);
- result(nil);
- } else if ([call.method isEqualToString:@"clearShortcutItems"]) {
- [UIApplication sharedApplication].shortcutItems = @[];
- result(nil);
- } else if ([call.method isEqualToString:@"getLaunchAction"]) {
- result(nil);
+ if (@available(iOS 9.0, *)) {
+ if ([call.method isEqualToString:@"setShortcutItems"]) {
+ _setShortcutItems(call.arguments);
+ result(nil);
+ } else if ([call.method isEqualToString:@"clearShortcutItems"]) {
+ [UIApplication sharedApplication].shortcutItems = @[];
+ result(nil);
+ } else if ([call.method isEqualToString:@"getLaunchAction"]) {
+ result(nil);
+ } else {
+ result(FlutterMethodNotImplemented);
+ }
} else {
- result(FlutterMethodNotImplemented);
+ NSLog(@"Shortcuts are not supported prior to iOS 9.");
+ result(nil);
}
}
- (void)dealloc {
- [self.channel setMethodCallHandler:nil];
- self.channel = nil;
+ [_channel setMethodCallHandler:nil];
+ _channel = nil;
}
- (BOOL)application:(UIApplication *)application
performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem
- completionHandler:(void (^)(BOOL succeeded))completionHandler {
+ completionHandler:(void (^)(BOOL succeeded))completionHandler
+ API_AVAILABLE(ios(9.0)) {
[self.channel invokeMethod:@"launch" arguments:shortcutItem.type];
return YES;
}
#pragma mark Private functions
-static void setShortcutItems(NSArray *items) {
- NSMutableArray *newShortcuts = [[NSMutableArray alloc] init];
+NS_INLINE void _setShortcutItems(NSArray *items) API_AVAILABLE(ios(9.0)) {
+ NSMutableArray<UIApplicationShortcutItem *> *newShortcuts = [[NSMutableArray alloc] init];
for (id item in items) {
- UIApplicationShortcutItem *shortcut = deserializeShortcutItem(item);
+ UIApplicationShortcutItem *shortcut = _deserializeShortcutItem(item);
[newShortcuts addObject:shortcut];
}
[UIApplication sharedApplication].shortcutItems = newShortcuts;
}
-static UIApplicationShortcutItem *deserializeShortcutItem(NSDictionary *serialized) {
+NS_INLINE UIApplicationShortcutItem *_deserializeShortcutItem(NSDictionary *serialized)
+ API_AVAILABLE(ios(9.0)) {
UIApplicationShortcutIcon *icon =
[serialized[@"icon"] isKindOfClass:[NSNull class]]
? nil
diff --git a/packages/quick_actions/ios/quick_actions.podspec b/packages/quick_actions/ios/quick_actions.podspec
index 3304d83..b7d56bf 100644
--- a/packages/quick_actions/ios/quick_actions.podspec
+++ b/packages/quick_actions/ios/quick_actions.podspec
@@ -4,14 +4,16 @@
Pod::Spec.new do |s|
s.name = 'quick_actions'
s.version = '0.0.1'
- s.summary = 'A new flutter plugin project.'
+ s.summary = 'Flutter Quick Actions'
s.description = <<-DESC
-A new flutter plugin project.
+This Flutter plugin allows you to manage and interact with the application's home screen quick actions.
+Downloaded by pub (not CocoaPods).
DESC
- s.homepage = 'http://example.com'
- s.license = { :file => '../LICENSE' }
- s.author = { 'Your Company' => 'email@example.com' }
- s.source = { :path => '.' }
+ s.homepage = 'https://github.com/flutter/plugins'
+ s.license = { :type => 'BSD', :file => '../LICENSE' }
+ s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
+ s.source = { :http => 'https://github.com/flutter/plugins/tree/master/packages/quick_actions' }
+ s.documentation_url = 'https://pub.dev/packages/quick_actions'
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'