iOS Share vs Action App Extension

后端 未结 1 461
情书的邮戳
情书的邮戳 2020-12-22 20:20

I want to implement an app extension, but I can\'t decide if I should implement it as a Share Extension or Action Extension.

The documentation doesn\'t say much abou

相关标签:
1条回答
  • 2020-12-22 20:44

    Here are my findings so far:

    Summary:

    • Icon: Share extensions have colored icons.
    • Icon location: Some apps, like Safari, have a large amount of un-hiddable activity icons that your icon would be competing with.
    • User Interface: Share extensions should have a consistent UI.
    • Intent: Share extensions are meant to be reserved for sharing content, but even Apple violates this requirement.

    Icon

    Share extensions get a colored icon, which is the same one as your app's main icon. In fact, Apple states: "If you provide a separate icon in your Share extension target, Xcode ignores it."[B]

    Action extensions use "a monochromatic version of the app icon,"[E] or "a template image version"[B] of your app icon.


    Icon location

    Share extensions appear in the middle row, action extensions appear on the bottom row.

    Depending on the app being targeted, your icon may be competing with more or less icons as an share vs. action extension. For example, if users are going to access your extension through Safari mainly, your app would be competing with 4 other icons by default as a share extension*, or 8 other icons as an action extension. On the other hand, if you are targeting the Maps app, you would be competing with more icons as a share extension (4) rather than an action extension (2).

    Therefore, to maximize your exposure to the user you would want to choose a share extension when targeting Safari, but an action extension when targeting Maps.

    Note: Most of the activities are provided by the host app itself using the UIActivity and UIActivityViewController APIs. There is a great write-up about them on NSHipster.

    *Obviously the number of share and activity extensions change depending on the installed apps and which the user chose to show/hide.

    Examples from the iOS 9.1 Simulator:

    • Contacts:
      • Share (1): Mail
      • Activities (0):
    • Maps:
      • Share (4): Mail, Reminders, Twitter, Facebook
      • Activities (2): Add to Favorites, Print
    • News:
      • Share (4): Mail, Reminders, Twitter, Facebook
      • Activities (5): Add to Reading List, Copy, Open in Safari, Report a Concern, Mute Channel
    • Photos:
      • Share (4): Mail, Twitter, Facebook, Flickr
      • Activities (6): Copy, Slideshow, Hide, Assign to Contact, Use as Wallpaper, Print
    • Safari:
      • Share (4): Mail, Reminders, Twitter, Facebook
      • Activities (10): Add to Favorites, Add Bookmark, Add to Reading List, Add to Home Screen, Add to Shared Links, Add to News, Copy, Print, Find on Page, Request Desktop Site
    • (Highlighted Text):
      • Share (3): Mail, Twitter, Facebook
      • Activities (1): Copy

    (Italics means the icons can be hidden.)


    User Interface

    The default Share extension template comes with a subclass of SLComposeServiceViewController to keep things consistent. And Apple wants you to "use the system-provided UI in a Share extension [as much as possible]."[E]

    Action extensions, on the other hand, allow you to choose an Action Type (Presents User Interface or No User Interface), with the former coming with a blank UIViewController.


    Default share extension; Default Presents User Interface Action extension.


    Intent

    Although Apple states that a Share extension should "post to a sharing website or share content with others,"[A] even they violate this requirement with Reminders.

    Action extensions are meant to "manipulate or view content originating in a host app."[A]


    Things that are the same

    • Both allow your app to provide multiple versions of the extension. (E.g. your app could provide two share extensions and two action extensions.)
    • In my limited testing, they both seem to be disabled by default, with the user having to explicitly tap on the more button to enable the share/action extension.

    References

    • A: App Extensions Increase Your Impact in the App Extension Programming Guide
    • B: Creating an App Extension in the App Extension Programming Guide
    • C: Share in the App Extension Programming Guide
    • D: Action in the App Extension Programming Guide
    • E: App Extensions in the iOS Human Interface Guidelines
    0 讨论(0)
提交回复
热议问题