Wednesday, October 15, 2014

Introduction to Extension



Extension is the new feature of iOS 8 & OS X Yosemite (v10.10) which allows the third party app to communicate with other apps. It allows the developers to extend the app functionality & content beyond the application & make it available to the users while using other applications. 

Some example of Extension are-

1) Show the app as widget on the Today Screen.
2) Use the photo filters within the iOS photo app.
3) Provide custom keyboard that users can use in place of iOS system keyboard. 

Extension is different from the app and designed for the specific task and will end itself when the task is completed. Application acts as a container for your extensions.

Note- Memory limits for running app extension is lower than the memory limits provided to the foreground app.


Types of Extension-

There are 7 types of Extension each of which is tied to an area of system known as Extension points. Each extension point defines usage policy & provides APIs that developer will use when they create an extension for that area. Since each extension point is associated to usage policies and specific APIs, developers have to choose the appropriate extension point for the type of functionality they want to provide. Out of 7 extension, 6 is available in iOS 8 & 4 in OX X Yosemite.

1) Today- Today Extension is also named as Widget can be used to show quick update or perform quick task in the Today View of notification centre. It is available in both iOS & OS X. 

2) Share- If you want to share images or contents then you can use Share Extension to post the content on the Website. It is available in both iOS& OS X.

3) Action- This extension manipulate or view content within the context of another app. It is available in iOS & OS X.

4) PhotoEditing- This extension provides the ability to edit the photo or video within the Photos app. It is available in iOS only.

5) FinderSync- This extension provides the ability to modify the behaviour of Finder. Unlike other apps its does not provides the functionality to add features to other apps. It is available in OS X only.

6) Document Provider- This extension provides access to & manage a repository of files. It is available in iOS only.

7) Custom keyboard- This extension replace the iOS system keyboard with the custom keyboard. It is available in iOS only.


Extension’s life cycle-

Extension lifecycle & environment is different from the app.  System instantiates the extension when host app request for it. Host app defines the context provided to the extension and starts the extension life cycle when it sends a request in response to a user action. Extension terminates soon after it completes the request it received from the host app.




eg- Suppose user finds some content in Safari to share and taps the share button then its shows all the available extension. Here, Safari is the host app & by choosing the extension host app request the extension to perform the task to share the selected content. When the task is completed then the extension will send the response to the Host app.


How an App extension communicates-

Host app communicates with the Extension. Host app request the extension & after completing the request extension will send the response to host app. 



There is no direct communication between app extension & its containing app & also host will not communicates with the extension’s container. However, Indirect communication is available using well-defined API’s. Extension can open the containing app by using the openURL method and access the shared resources by using NSUserDefaults.





How to create Extension-

You can create the app extension by adding new target to the app. You can add multiple extension to a application.


How to deliver Extension to the users-

To deliver the Extension to the users, you submit application containing extension to the app store. When user installs the app containing extension, then extension will automatically installed in the device. 


Limitations-

1) Health Kit and Event Kit UI Frameworks are not available.
2) Extensions cannot perform long running background tasks.
3) Extensions cannot access the device’s cameras or microphones (although they may access existing media files)
4) Extensions cannot receive Air Drop data (although they can transmit data via Air Drop)
5) Extension cannot access the sharedApplication object so cannot use any of the methods on that object.


Note- API’s which are not available for extensions are marked with an unavailability macro "NS_EXTENSION_UNAVAILABLE".


No comments:

Post a Comment