In my app, I would like to share shopping list. Let's say, I would like to share the shopping list in two different ways:
- Through
AirDrop
with aschema url
, which will bring up my app on another device, and the receiving app adds the shared items to its shopping list. - Through
email
, which sends anemail
with the items on the shopping list as aHTML document
in a table format.
So bascially there are two different strings to be shared across depend on whether the activity type is AirDrop
or email
. The below code does not work, in the sense that it is always the schema URL
got sent, even for email
:
url = [@"myapp://shoppinglist?apple=12&orange=5" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[url] applicationActivities:nil];
[self presentViewController:controller animated:NO completion:nil];
I dug a bit, but could not find out how to send different contents based on the method of sharing.
My question is how to do what I described here with UIActivityViewController
? Or whether it is even doable - whether UIActivityViewController
was meant for this or has the flexibility for doing this?