New AirDrop iOS 7 feature

I am trying to implement the AirDrop function in an iOS application. However, I cannot find any specific tutorial or resources regarding this feature. Can someone please provide me a sample or a link to implement AirDrop in iOS 7?

Any help is much appreciated, thanks.

+4
source share
3 answers

Airdrop is a feature that has been added to the currently available UIActivityViewController . If the user has iOS7 on a supported device (iPad mini, iPad 4, iPhone 5, iPhone 5c, iPhone 5s), then airdrop should be available for them as another option, unless you explicitly exclude this activity.

+9
source

Try this inline function. Do this in the button selector.

 UIDocumentInteractionController *interaction = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileToTransferPath]]; //fileToTransferPath can be the path of a file supported by airdrop feature. interaction.delegate = self; [interaction presentOpenInMenuFromRect:sender.frame inView:self.view animated:NO]; 

Remember to add the UIDocumentInteractionControllerDelegate to the .h file.

+5
source

Suppose you want to share a URL with someone. You can do it like this using the UIActivityViewController:

 // Build a collection of activity items to share, in this case a url NSArray *activityItems = @[[NSURL URLWithString:link]]; // Build a collection of custom activities (if you have any) NSMutableArray *customActivities = [[NSMutableArray alloc] init]; UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:customActivities]; [self presentViewController:activityController animated:YES completion:nil]; 

It will also automatically give you access to other sharing features, unless you disable them through the customActivities collection.

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivityViewController_Class/Reference/Reference.html

+1
source

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


All Articles