iOS共享与动作应用扩展 [英] iOS Share vs Action App Extension

查看:151
本文介绍了iOS共享与动作应用扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现应用扩展程序,但我无法决定是否应将其作为共享扩展程序或操作扩展程序实现。








图标location



共享扩展程序显示在中间行,操作扩展名显示在底行。



取决于应用作为目标,您的图标可能会与或多或少的图标竞争作为共享与行动扩展。例如,如果用户主要通过Safari访问您的扩展程序,则您的应用程序将默认与其他4个图标竞争共享扩展程序*,或其他8个图标作为操作扩展程序。另一方面,如果您要定位地图应用,则会将更多图标作为共享扩展(4)而不是动作扩展(2)进行竞争。



因此,为了最大限度地提高您对用户的曝光率,您希望在定位Safari时选择共享扩展程序,但在定位Google地图时选择操作扩展程序。



注意:大多数活动由主机应用程序本身使用

默认共享扩展名;默认提供用户界面操作扩展。







意图



虽然Apple声明分享扩展程序应发布到共享网站或与他人共享内容,但 [A] 即使他们违反了提醒的这一要求。



动作扩展程序旨在操纵或查看源自主机应用程序的内容。 [A]






相同的事情




  • 两者都允许您的应用提供多个版本的扩展程序。 (例如,您的应用可以提供两个共享扩展和两个操作扩展。)

  • 在我的有限测试中,默认情况下它们似乎都被禁用,用户必须明确点击更多按钮以启用共享/操作扩展。






参考




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 about the differences, just this:

  • Share (iOS and OS X): Post to a sharing website or share content with others
  • Action (iOS and OS X; UI and non-UI variants): Manipulate or view content originating in a host app

Are there technical differences as well (e.g. does an Action extension allow me to do something that the Share extension doesn't), or is it merely a convention Apple wants you to follow to make things less confusing to users?

It seems that at least one difference is that if you want a non-UI action, you must choose an Action instead of Share extension.

What are the other differences?

Examples of things I'm looking for:

  • Do they both allow me to customize the UI?
  • Do the both give me some default UI to use?
  • Do they both have the same permissions, or am I allowed to do more things in one vs. the other?
  • Do they both receive the same input from the Host app?
  • Can they both send back the same data to the Host app?

解决方案

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

这篇关于iOS共享与动作应用扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆