Forum Xamarin.iOS

How to share and receive audio file from and to xamarin ios app?

mishtyNaikmishtyNaik INMember ✭✭
edited July 2016 in Xamarin.iOS

How can I share a audio file from my app to other apps and receive audio files from other apps?

I would like a functionality like this:

I am unable to attach a audio file. Here is the code snippet:

var fileDAta = NSUrl.FromFilename(path);
var item = UIActivity.FromObject(@"URL: " + url + "");// NSObject.FromObject(uiImage);
var activityItems = new[] { fileDAta };
NSString message = (NSString)"Test";
var activityController = new UIActivityViewController(activityItems, null);
activityController.SetValueForKey(NSObject.FromObject("The subject value"), new NSString("subject"));
var topController = UIApplication.SharedApplication.KeyWindow.RootViewController;
while (topController.PresentedViewController != null)
{
topController = topController.PresentedViewController;
}
topController.PresentViewController(activityController, true, () => { });

I would also like to add subject and body if file attached as mail.

tried this but no luck, getting an error.:

activityController.SetValueForKey(NSObject.FromObject("The subject value"), new NSString("subject"));
activityController.SetValueForKey(NSObject.FromObject("The body value"), new NSString("body"));

I also want other apps to be able to share audio file to my app? How can I achieve this?

Sign In or Register to comment.