Reputation: 6714
I am trying to implement AirDrop
feature in my iOS Application. However, I am unable to find any specific tutorial or resources regarding this feature. Can someone please provide me with a sample, or a link, regarding the implementation of the AirDrop
feature in iOS 7?
Any help is highly appreciated, thanks.
Upvotes: 4
Views: 4610
Reputation: 939
Try this, its built in feature. Do this in your 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];
Don't forget to add UIDocumentInteractionControllerDelegate in .h file.
Upvotes: 5
Reputation: 20257
Lets say 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];
This would also give you access to other social sharing functions automatically, unless you disable them through the customActivities collection.
Upvotes: 1
Reputation: 736
Airdrop is a feature that was added to the currently available UIActivityViewController. If a user has iOS7 on a supported device (iPad mini, iPad 4, iPhone 5, iPhone 5c, iPhone 5s), then airdrop should be available to them as just another option, unless you explicitly exclude that activity.
Upvotes: 9