Inherits from | NSObject |
Conforms to | INKActivityViewControllerDefaultsDelegate |
Declared in | INKHandler.h |
Overview
INKHandler
is the base class for shared groups of behavior for a class of third-party applications. You cannot use the INKHandler
class directly. It instead defines the common interface and behavioral structure for all its subclasses.
Subclassing Notes
If you are defining URL schemes for a new discrete class of third-party applications (such as “web browsers” or “mapping applications”, you may want to create your own INKHandler
subclass. All custom methods you create that perform actions should ultimately return a UIActivityController created by calling performCommand:withArguments:.
Tasks
-
defaultApp
The name of the currently-registered default app. This app might not be able to handle all actions; in that case, a fallback activity view will be shown.
property -
disableSettingDefault
If YES, when this handler is presented as an activity sheet, it will never show the “Remember My Choice” toggle.
property -
showFirstPartyApp
By default, if a handler has both a first-party app and an in-app modal view (e.g. Safari and an in-app UIWebView), the first-party app won’t be displayed.
property -
disableInAppOption
If a handler has an “In App” option (e.g. an in-app UIWebView for INKBrowserHandler), setting this to YES will disable it
property -
useFallback
If no apps are available to perform a given task, if
propertyfallback
is set to YES then the handler will attempt to perform the task in a web browser instead. YES by default. -
alwaysShowActivityView
By default, if there is only one valid application, a handler will automatically open that app instead of showing a
propertyINKActivityViewController
. Setting this toYES
overrides that behavior and always shows an activity view. -
useSystemDefault
If true, this handler object will use a system-provided default if the user has not provided one.
property -
– canPerformCommand:
Returns whether or not an action can be performed at all.
-
– performCommand:withArguments:
Opens a third-party application to perform some task. If there is only one application installed that can respond to that command, it will open that app with the correct URL. Otherwise, it will create a
UIActivityViewController
to prompt the user to pick an app. -
+ category
The category of activity handled by the handler. This is used to group handlers in INKDefaultsViewController
-
+ name
The name of the class of applications represented by the handler.
-
– promptToSetDefault
Prompts the user to pick a default application for the handler
Properties
alwaysShowActivityView 
@property (nonatomic, assign) BOOL alwaysShowActivityView
Discussion
By default, if there is only one valid application, a handler will automatically open that app instead of showing a INKActivityViewController
. Setting this to YES
overrides that behavior and always shows an activity view.
This is mostly useful for demo purposes (e.g. running in the simulator).
Declared In
INKHandler.h
defaultApp 
@property (readonly) NSString *defaultApp
Discussion
The name of the currently-registered default app. This app might not be able to handle all actions; in that case, a fallback activity view will be shown.
Declared In
INKHandler.h
disableInAppOption 
@property (nonatomic, assign) BOOL disableInAppOption
Discussion
If a handler has an “In App” option (e.g. an in-app UIWebView for INKBrowserHandler), setting this to YES will disable it
Declared In
INKHandler.h
disableSettingDefault 
@property (assign, nonatomic) BOOL disableSettingDefault
Discussion
If YES, when this handler is presented as an activity sheet, it will never show the “Remember My Choice” toggle.
Declared In
INKHandler.h
showFirstPartyApp 
@property (nonatomic, assign) BOOL showFirstPartyApp
Discussion
By default, if a handler has both a first-party app and an in-app modal view (e.g. Safari and an in-app UIWebView), the first-party app won’t be displayed.
Setting this to YES will show the first-party app as an option.
Declared In
INKHandler.h
useFallback 
@property (nonatomic) BOOL useFallback
Discussion
If no apps are available to perform a given task, if fallback
is set to YES then the handler will attempt to perform the task in a web browser instead. YES by default.
Declared In
INKHandler.h
useSystemDefault 
@property (nonatomic, assign) BOOL useSystemDefault
Discussion
If true, this handler object will use a system-provided default if the user has not provided one.
To be clear: this means that performing an action with this handler will NEVER prompt the user to set a preference. In order to allow user preferences if this option is set, you will need to give users a way to explicitly set preferences, either by using an INKDefaultsViewController
or creating your own interface.
Declared In
INKHandler.h
Class Methods
category 
+ (INKHandlerCategory)category
Discussion
The category of activity handled by the handler. This is used to group handlers in INKDefaultsViewController
Declared In
INKHandler.h
Instance Methods
canPerformCommand: 
- (BOOL)canPerformCommand:(NSString *)command
Discussion
Returns whether or not an action can be performed at all.
Parameters
- command
The name of a command to perform, corresponding with the keys in each application’s plist.
Return Value
YES if the user has at least one application installed that responds to the given command.
Declared In
INKHandler.h
performCommand:withArguments: 
- (INKActivityPresenter *)performCommand:(NSString *)command withArguments:(NSDictionary *)args
Discussion
Opens a third-party application to perform some task. If there is only one application installed that can respond to that command, it will open that app with the correct URL. Otherwise, it will create a UIActivityViewController
to prompt the user to pick an app.
Parameters
- command
The name of a command to perform, corresponding with keys in each application’s plist.
- args
The dictionary of arguments used to construct a URL based on the templates defined for each URL scheme.
Return Value
A INKActivityPresenter
object to present.
Declared In
INKHandler.h
promptToSetDefault 
- (INKActivityPresenter *)promptToSetDefault
Discussion
Prompts the user to pick a default application for the handler
Return Value
An INKActivityPresenter
object to present.
Declared In
INKHandler.h