IOS8 expansion plug-in development configuration

Source: Internet
Author: User

A IOS8 Extensions Overview

In addition to the release of OS X v10.10 and SWITF, the WWDC14 also began to become more open in iOS8.0. When it comes to openness, of course, it's app extensions (app Extension). As the name implies, app extensions allow developers to extend the app's custom features and content, allowing them to use the functionality of other applications, enabling functionality and resource sharing across applications. The extension can be understood as a lightweight (nimble and lightweight) clone.

The following are the common three types of plugins:

Target Type

Extension Point Identifier

Scenarios

Today Extension

Com.apple.widget-extension

System Notification bar drop-down display

Share Extension

Com.apple.share-services

Host App(Photos, Safari, mail, voice, etc.) share menu first line

Action Extension (UI)

Com.apple.ui-services

Host App(Photos, Safari, mail, voice, etc.) Share menu second line

Share for photos in Iphone/ios8:

For example "" supports sharing up to 9 photos (nsextensionactivationsupportsimagewithmaxcount=9) to friends or to a friend circle.

Two Plug-in working mechanism
1. Plugins can only communicate directly with the host app through the context


2. Plug-ins can communicate indirectly with the containing app via the shared resource area


3.Host app-extension-containing App Workflow
    • The Host App --share/actionextension Extension (*.appex) by tapping the plugin icon in the System share menu.
    • The iOS system (Host App) passes the extended context (Nsextensioncontext) to the share/actionextension to share the data.
    • share/action Extension extracts the data and serializes it to the shared resource area identified with the AppGroup ID nsuserdefaults/appgroup Container (Containerurlforsecurityapplicationgroupidentifier).
    • Share/action extension calls Containingapp via URL scheme , and the plugin sends a request completion notification via context to the iOS system (Hostapp). To return to the host APP (iOS system will dismiss plugin Uiviewcontroller).
    • The containing app reads the shared data from the Nsuserdefaults/containerurl through the app Group ID, and then processes the share.

This shows that the extension plug-in hosts the host app with the containing app, while app Group container the bridge of data interaction.

It is important to note that in iOS 8.0, only today extension supports direct calls to Nsextensioncontext 's openurl:completionhandler: Open the URL link; share/action extension to implement URL Scheme, you can only create a Sink uiwebvew loadrequest The URL to achieve the salvation (so-called "Sink "means to be hidden but not apparent, for example Frame=cgrectzero).

4. Plug-in UI patterns

The plugin exists in uiviewcontroller mode on the UI and is ejected as a modal window by the Parentviewcontroller (Host App) (present as modal Viewcontroller).

The plug-in project specifies UI view portals through Nsextensionmainstoryboard in the nsextension of Info.plist. Of course, if you do not want to use storyboard, you can also use nsextensionprincipalclass Specifies the custom Uiviewcontroller subclass name (which can also be encapsulated into Uinavigationcontroller).

Attention:

    • After you create a new extension Target (Deployment target≥8.0), you need to build settings| architectures| Add arm64in Valid architectures!
    • When the containing app was initially installed, the extension was not enabled and needed to open the switch in "more".
Three Limitations of plugins

The following text excerpt from "APP Extension Programming Guide", mainly lists the limitations of the plugin, in order to know that it can not be.

--------------------------------------------------------------------------------

1.Design a streamlined UI
    • An extension ' s UI should is simple, restrained, and focused on facilitating a single task.
    • To improve performance and the user's experience, avoid including extraneous UI that doesn ' t support your Extensi On ' s main task.
2.Optimize Efficiency and performance

(1) APP extensions should feel nimble and lightweight to users.

    • Design your app extension to launch quickly, aiming for well under one second.
    • An extension that launches too slowly are terminated by the system.

(2) memory limits for running app extensions is significantly lower than the memory limits imposed on a foreground a Pp.

    • On both platforms, the system could aggressively terminate extensions because users want to return to their main goal in the Host app.
    • Some extensions may have lower memory limits than others.

(3) Your app extension doesn ' t own the main run loop, so it's crucial that you follow the established rules for good behavior In main runloops.

    • For example, if your extension blocks the main runloop, it can create a bad user experience in another extension or app.

(4) Keep in mind that theGPUs are a shared resource in the system.

    • APP extensions does not get top priority for shared resources; For example, a Today widget, runs a graphics-intensive game might give users a bad experience. The system is likely to terminate such an extension because of memory pressure.
    • Functionality that makes heavy the use of the system resources is appropriate for the app, not an app extension.

--------------------------------------------------------------------------------

This shows that the iOS system requires simplicity in plug-ins: Faster UI startup, less memory consumption, and runloop execution time.

The limitations of the iOS system on plug-ins have determined that plug-ins must be lightweight, twitter/, small picture file sharing, url jumps or not, and it's not appropriate to expect a rich, flashy UI or a big-bang file to be sent.

Of course, if you want to extend (even exit) a long-time task (such as upload/download), you can use nsurlsession to create an upload/download session and initialize a background upload/download task.

Attention:

Apple also limits the extension's access to API usage, and API prototype declarations that are disabled in the extension are labeled ns_extension_unavailable macros. For example:

+ (uiapplication*) sharedapplication Ns_extension_unavailable_ios;

The sharedapplication restriction is actually to not allow the plugin to get access to the host app's UIApplication object directly.

Four. Media types supported by the share/action extension Configuration

The nsextension| in Info.plist nsextensionattributes| Nsextensionactivationrule Dictionary can configure the type and number of media supported by the plugin:

iOS extensions support media type configuration keys

Describe

Configuration

Description

Nsextensionactivationsupportsattachmentswithmaxcount

Attachments Maximum Limit

20

The attachment includes the following file, image, and movie categories, with a single, mixed selection of no more than 20

Nsextensionactivationsupportsattachmentswithmincount

Minimum attachment limit

Above non-zero, default=1

The extension icon is not displayed in share until at least 1 attachments are selected by default

NsextensionactivationsupportsFilewithmaxcount

Maximum file limit

20

The file refers to attachments other than Image/movie, such as "Mail" attachments, "voice memos", and so on.

No more than 20 for single and mixed selection.

NsextensionactivationsupportsImagewithmaxcount

Maximum picture limit

20

No more than 20 for single and mixed selection

NsextensionactivationsupportsMoviewithmaxcount

Maximum video limit

20

No more than 20 for single and mixed selection

NsextensionactivationsupportsText

Text type

Default=0

Text sharing is not supported by default, such as "Memo"

NsextensionactivationsupportsWebURLwithmaxcount

Web links up to limit

Default=0

Sharing hyperlinks is not supported by default, such as "Safari"

Nsextensionactivationsupportswebpagewithmaxcount

Maximum Web page limit

Default=0

Web page sharing is not supported by default, such as "Safari"

The Host app provides a context (Nsextensioncontext) to pass data to the extension (Appex), containing the data to be processed (inputitems). The data passed is a set of Nsextensionitem objects, where attachments such as pictures, videos, and URLs to be shared are stored in the Nsextensionitem attachments array.

For UTIs, refer to Uniformtype Identifiers Reference | system-declared Uniform Type Identifiers.

Media type

File UTI

picture (public.image)

Kuttypeimage

Kuttypejpeg

Kuttypepng

Kuttypegif

Kuttypetiff

Kuttypebmp

Kuttypeico

video (Public.movie)

Kuttypemovie

Kuttypequicktimemovie

Kuttypempeg

KUTTypeMPEG4

Kuttypeavimovie

@ "PUBLIC.3GPP"

@ "Com.real.realmedia"

@ "Com.microsoft.windows-media-wmv"

@ "Com.microsoft.advanced-systems-format"

Audio (Public.audio)

Kuttypeaudio

KUTTypeMP3

Kuttypempeg4audio

Kuttypewaveformaudio

@ "Com.microsoft.windows-media-wma"

Document

Kuttypepdf

@ "Com.microsoft.word.doc"

@ "Com.microsoft.excel.xls"

Kuttypepresentation

@ "Com.microsoft.powerpoint.ppt"

@ "Com.apple.keynote.key"

Compress package

Kuttypeziparchive

Kuttypegnuziparchive

Kuttypebzip2archive

@ "Public.tar-archive"

@ "Org.gnu.gnu-zip-tar-archive"

Five App Group certificate configuration for plugins and containing apps

The containing app and its extension are shared through the shared Ziyuan District-app group Container identified by the app group ID.

The app ID for the containing app and its extension must be Explicit, and the extension app ID must be containing with the Prefix/seed app ID and configured to the same app Group below.

App ID is configured in Info.plist Bundleidentifier, and app group is at Target's "Xcode target| Capabilities "enabled in, configure to" Xcode target| Build settings| Code signing| Code Signing entitlements "in the com.apple.security.application-groups of the *.entitlements file

The key.

Certificate and Provisioning profile application and code signing configuration process with previous common app, please refer to "iOS Development Certificate Essentials" for details.
Six Build phases configuration for containing app (embed app extensions)

Containing APP's "Xcode target| buildphases| Target Dependencies "can add or remove plug-in target.

Containing APP's "Xcode target| buildphases| Plug-in product (*.APPEX) can be added or removed from Embed App Extensions "under destination for plugins.

Note : By default, "Copy only when installing" is selected, which means that the plug-in is copied from the AppStore installation, including the upgrade overlay. Xcode connection to the real-time debugging, you need to cancel The change, or the System "share" menu does not appear in the plugin

IOS8 expansion plug-in development configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.