Links

Share Extensions - Recap

Share Extensions are used to share Audio, Video, Photos, Comments, Links etc, from supported app. In case of web content an app can specify the two types of input i.e; Web URL and Web Page. Web URL is simply the current URL as a string but the Web Page is full HTML of the shared page based on the JS provided by the host app.

Basic requirments to register an app for sharing;
  1. Display Name - CFBundleDisplayName
  2. Activition Rules - Inform the iOS about what kind to data they support to share, based on the same iOS will select the app to be shown in sharing menu. App should have appropriate information in ".plist" file @ NSExtension -> NSExtensionAttributes -> NSExtensionActivationRule. There are two ways to supply this information, i.e;
    • Predicates - A complex or simple predicate with supported types, in this case NSExtensionActivationRule will be string type
    • Condensed - A simple list of supported sharing types, in this case NSExtensionActivationRule will be dictionary type
    An app can specify the ammount of data it can take at a time in the activation rules.
  3. ViewController - App need to provide a ViewController subclassed with SLComposeServiceViewController which will be displayed at the time of sharing


NOTE:For Share Extensions we should use NSURLSession to perform server data transfears the reason being your extension does not live beyond its presentation.

Basic settings of SLComposeServiceViewController;
  1. PhotoBlogCharacterLimit - for max length of share message size
  2. PhotoBlogTmageDataMaxSize - for max image size
  3. - (BOOL)isContentValid method to return the runtime validation result, return false will disable the Post button
  4. - (NSArray *)configurationItems Returns configuration items to display in the compose view.
  5. AudiencePickerViewController/Delegate need to be implimented for privacy setting (Optional)

Post a Comment