3

I have some PDF in my app. I want to provide an option to open those PDF in other third party e-readers app that might be installed on the device, like Stanza and iBooks. Dropbox application has successfully implemented this feature and I can't find any information on how to detect what other e-readers are available on the device or what the custom url scheme is for those apps. Any help would be greatly appreciated. thanks in advance guys.

Hiren
  • 12,720
  • 7
  • 52
  • 72
Bittu
  • 676
  • 2
  • 8
  • 22
  • possible duplicate of [how to launch iBooks e-reader programmatically on iPad ?](http://stackoverflow.com/questions/2594321/how-to-launch-ibooks-e-reader-programmatically-on-ipad) – richq Jun 10 '11 at 16:00

3 Answers3

2

iBooks

NSString *stringURL = @"itms-books:";

NSURL *url = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication] openURL:url];

NSString *stringURL = @"itms-bookss:";

NSURL *url = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication] openURL:url];
Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
0

First of all you will need to create a NSURL object like so:

NSURL *url = [NSURL fileURLWithPath:file.FileName];

file.FileName --> your local file path where the document is stored in the local db.

UIDocumentInteractionController    *docController = [UIDocumentInteractionController interactionControllerWithURL:url];

docController.delegate = self;

[docController retain];

[docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

The following delegate methods will need to be implemented:

-(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
{

}

- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application
{

}

- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller
{

}
Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Magesh
  • 685
  • 2
  • 7
  • 15
-1

You don't need to detect the other apps, you need to know the url that can open them.

A call like this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];

Tells the phone to open the page in whatever app handles http/html requests which is safari. iBooks has their own url format which hopefully you can track down.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"ebook://iRobot.pdf"]];

NOTE: that's not correct, just meant to illustrate a different url scheme.

NWCoder
  • 5,296
  • 1
  • 26
  • 23