7. TEMPLATES
OSXDev.org
You can get an extension bundle that ends in .appex.
Each extension template includes
- a property list file (Info.plist).
- a view controller class (or principal class).
- a default user interface.
8. EXTENSION INFO
OSXDev.org
Info.plist file contains
- The extension point
- Some detail about extension.
NSExtensionPointIdentifier key has point’s reverse DNS name.
NSExtensionPrincipalClass key has extension view controller class.
NSExtensionMainStoryboard key has default storyboard file.
9. CONTEXT
OSXDev.org
Extensions receives the request, helps the user perform a task,
and completes or cancels the request, according to the user’s action
Extension can use ‘extensionContext' property on its principal view controller.
Use NSExtensionContext class to examine the context and get the items within it.
NSExtensionContext *myExtensionContext = [self extensionContext];
NSArray *inputItems = [myExtensionContext inputItems];
NSExtensionItem *item = [inputItems objectAtIndex:0];
Can get the context and items in loadView method
NSExtensionItem contains title, content text, attachments, user info
Extension gives user a choice between
- completeRequestReturingItems:expirationHandler:completion:
- cancelRequestWithError:
10. LIMITATION
OSXDev.org
Memory limits lower than foreground app.
Widget has lower memory limits than other extensions.
Extension don’t own the main run loop.
Extension don’t get top priority.
KEEP IN MIND FOR USER EXPERIENCE
11. SHARE CODE / DATA
OSXDev.org
Can use Embedded Framework both extension and containing app.
An API that extensions can’t use is marked NS_EXTENSION_UNAVAILABLE.
Sharing Code
Sharing Data
Can share data between containing app and extension through App Groups.
After you enable app groups, both can share data using NSUserDefaults API .
NSFileCoordinator and NSFilePresent API can ensure safe data sharing.
12. LONG-RUNNING TASK
OSXDev.org
In iOS, extension isn’t running when a background task completes,
the system launches containing app in the background and call
application:handleEventsForBackgroundURLSession:completionHandler:
14. TODAY
Get a QUICK update or perform a QUICK task
in the Today view of Notification Center.
(called a widget)
Based UIViewController NOT view.
Be available both iOS, OS X.
OSXDev.org
17. SHARE
Post to a sharing website or share content
with contents.
Apply to Bookmark, Photo related Apps.
Based SLComposeServiceViewController
or UIViewcontroller
Be available both iOS, OS X.
OSXDev.org
20. ACTION
Manipulate or view content within the context of
another app.
Lightweight tasks.
Be available both iOS, OS X.
OSXDev.org
Helps users view the current document.
Always appears in an action sheet or
full-screen modal view.
25. STORAGE PROVIDER
Choose a document from among the set of
documents the current iOS app can access.
Presents a UIDocumentMenuViewController.
OSXDev.org
UIDocumentPickerExtensionViewController
subclass is instantiated.
27. CUSTOM KEYBOARD
Replace the iOS system keyboard with
a custom keyboard for use in all apps
Only available iOS.
OSXDev.org
Based on UIInputViewController