How to handle Siri kit with INPlayMediaIntent to play podcast episode?

Published

I have followed all steps mentioned here for Siri:
https://docs.microsoft.com/en-us/xamarin/ios/platform/sirikit/implementing-sirikit?tabs=macos

Also followed: https://developer.apple.com/documentation/sirikit/media/managing_audio_with_sirikit

IntentHandler.cs:

[Register("IntentHandler")]
public class IntentHandler : INExtension, IINPlayMediaIntentHandling, IINAddMediaIntentHandling
{
    protected IntentHandler(IntPtr handle) : base(handle)
    { 
    }

    public override NSObject GetHandler(INIntent intent)
    {
        return this;
    }

    //INPlayMediaIntent

    public void resolveMediaItems(INPlayMediaIntent intent, Action<INPlayMediaMediaItemResolutionResult> completion)
    {
        var mediaItemData = new INMediaItem(identifier: SessionService.LastPlayedEpisode.PodcastId, title: SessionService.LastPlayedEpisode.Title, type: INMediaItemType.PodcastEpisode, artwork: null);
        MessagingCenter.Send<object, string>(this, "PlayRecentEpisodeSiriEvent", "ResolveMediaItems");
        completion(INPlayMediaMediaItemResolutionResult.GetSuccess(mediaItemData));
    }

    public void HandlePlayMedia(INPlayMediaIntent intent, Action<INPlayMediaIntentResponse> completion)
    {
        var userActivity = new NSUserActivity("INPlayMediaIntent");
        var response = new INPlayMediaIntentResponse(INPlayMediaIntentResponseCode.HandleInApp, userActivity);
        completion(response);
    }

    public void HandleAddMedia(INAddMediaIntent intent, Action<INAddMediaIntentResponse> completion)
    {
        var userActivity = new NSUserActivity("INAddMediaIntent");
        var response = new INAddMediaIntentResponse(INAddMediaIntentResponseCode.Success, userActivity);
        completion(response);
    }
}

Now, when I give command to Siri to like: "Play The Daily in myappname" it show this:

So, I am not getting actually how siri will handle Media content to show my app with command. Anyone know how to handle Siri Media Intent in Xamarin.iOS ? How to add Siri Support with Xamarin.iOS?

enter image description here

Source: Xamarin.ios Questions

Published
Categorised as Uncategorised Tagged , , , ,

Answers

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq