INExtension.GetHandler(INIntent) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Developers override this method to return the handler object if intent
is one their extension can respond to.
[Foundation.Export("handlerForIntent:")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 10, 0, ObjCRuntime.PlatformArchitecture.All, null)]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.WatchOS, 3, 2, ObjCRuntime.PlatformArchitecture.All, null)]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.MacOSX, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual Foundation.NSObject GetHandler (Intents.INIntent intent);
abstract member GetHandler : Intents.INIntent -> Foundation.NSObject
override this.GetHandler : Intents.INIntent -> Foundation.NSObject
Parameters
Returns
The developer's handler object or null
if intent
is not handled by the extension.
Implements
- Attributes
Remarks
The developer's handler object must implement the IIN{Intent}Handling
interface appropriate to the type(s) of INIntent for which this method returns the handler. For instance:
class MyExtension : INExtension
{
override public NSObject GetHandler (INIntent intent)
{
if (intent is INSendMessageIntent)
{
return new MySendMessageHandler ();
}
return null;
}
}
class MySendMessageHandler : NSObject, IINSendMessageIntentHandling
{
public void HandleSendMessage (INSendMessageIntent intent, Action<INSendMessageIntentResponse> completion)
{
// ... Send a message here ...
var activity = new NSUserActivity (nameof (INSendMessageIntent));
var response = new INSendMessageIntentResponse (INSendMessageIntentResponseCode.Success, activity);
completion (response);
}
}