Airdrop error message: "cannot get all of these items at once"

I use the following code to share an image, some text and a URL using a UIActivityViewController. Everything works fine, except that when use selects AirDrop, it gets "cannot receive all of these items at once." If I only share the image, then AirDrop works. I need text and URL for email, Facebook, Twitter sharing methods.

Is there a way to save the text and URL and make AirDrop only access the image, while Facebook, email, twitter sharing methods continue to use the text and URL along with the image I'm trying to use?

NSString *text = [NSString stringWithFormat:@"I made this image using %@ iOS app. Here is the link to download it:", [CloudHelper appName]]; NSURL *url = [NSURL URLWithString:APP_URL]; UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:@[text, url, myImage] applicationActivities:nil]; [self presentViewController:activityController animated:YES completion:nil]; 
+6
source share
1 answer

You want to create and share three objects that match the UIActivityItemSource , where you will return a string, one - an image and one URL. Then, when a delegate callback is called asking for an element, you check what type of activity was selected (Facebook, Twitter, airdrop, etc.), and you have some kind of feedback if that element is not applied.

So, in the case of airdrop, only the element source for the image will return a value other than zero. You can take a look at the airdrop example code to get some examples of how to implement the UIActivityItemSource

+8
source

Source: https://habr.com/ru/post/971316/


All Articles