1

I'm developing a PhoneGap Build application, but needed a way to prompt my user to open local files in Adobe Reader (inAppBrowser will not work for my situation). I found a 3rd party plugin for PhoneGap that does what I need. However it only does it for remote .pdf files. I have figured out how to alter the plugin code to work with local files on the iPad/iPhone but it seems to close my application when the user opens the pdf in Adobe Reader.

I know almost nothing about objective C, Xcode, etc.

Desired functionality is:

  1. User navigates my app searching or browsing for files
  2. Finds desired file
  3. Selects file
  4. User is presented with "open with" options of which one is Adobe reader
  5. User selects Adobe, PDF opens
  6. User returns to my app in location they left it

I have it all working except on step #6 above my app seems to be closed. If I press the home button twice app show up at the bottom of iPad but when selected app starts from closed state showing splash screen. I'd like it to be where the user left it.

I believe the relevant code is

NSURL *fileURL = [NSURL fileURLWithPath:localFile];

UIDocumentInteractionController *controller = [UIDocumentInteractionController  interactionControllerWithURL:fileURL];
[controller retain];
controller.delegate = self;
controller.UTI = uti;

CDVViewController* cont = (CDVViewController*)[ super viewController ];
//CGRect rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height);
CGRect rect = CGRectMake(0, 0, 1024, 768);
[controller presentOpenInMenuFromRect:rect inView:cont.view animated:YES];

pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @""];
[self writeJavascript: [pluginResult toSuccessCallbackString:callbackID]];

[callbackID release];
[path release];
[uti release];

Where this line

[controller presentOpenInMenuFromRect:rect inView:cont.view animated:YES];

prompts the user to select Adobe. Is there a parameter I can pass here to not have my application shut down once the user selects to open the pdf in Adobe?

Thanks!

The plugin I have altered in its original state can be found and discussed here: http://www.tricedesigns.com/2012/08/15/open-with-in-ios-phonegap-apps/

RichP
  • 525
  • 1
  • 10
  • 25
  • Can you know the reason make your app crash? You could try uncatch-exception to know that – Tony Aug 01 '13 at 07:58

0 Answers0