UIActivityViewController completion handler terminated using AirDrop

I use the UIActivityViewController to share some texts and URLs that work fine when sending some text and URLs.

Currently, I need to use the completion handler to perform additional actions, depending on whether the user UIActivityViewController or actually sent something.

The completion handler ( activityViewController.completionHandler for iOS 7 is deprecated in iOS 8, which is now activityViewController setCompletionWithItemsHandler ) returns a BOOL completed value that correctly returns true when sending via Facebook sms email however, when sending via Airdrop user must click Cancel to reject the sent UIActivityViewController , and therefore I always get false from the completion handler.

Does anyone know if there is a way to find out what the user sent using Airdrop when the UIActivityViewController rejected?

thanks

+4
source share
1 answer

I found something interesting for you, but, unfortunately, I could not check it, because AirDrop did not want to function between my iDevices. Sorry.

Anyway, you can try setCompletionWithItemsHandler to check activityType :

 [activityViewController setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) { NSLog(@"completed: %@, \n%d, \n%@, \n%@,", activityType, completed, returnedItems, activityError); }]; 

If activityType is of type com.apple.airdrop.etc (just a hunch), the user clicks on the icon. Hope this helps.

+13
source

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


All Articles