-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
showOpenWithDialog is not working #145
Comments
Some more details after spending a day on it... Here's my code for downloading the PDF:
In the "open the file here" section above, I've tried these (this first 2 window.open calls both work with either toURL or toInternalURL, and fileopener2.open works with toURL but not toInternalURL)
|
I am sorry, I don't have an iDevice at the moment to test. The iOS code was generously contributed by @stalniy Try to message him and ask maybe he can help you. |
First of all, you need to pass real fs url (not cdv://). Second, open with dialog will not be shown if you don't have an app which can open such file. Third, it most likely will not work on emulator because emulator doesn't have apps which can open pdf |
thanks for replying @stalniy! |
Thanks @stalniy -- Yes I was able to figure out the real fs url and not cdv:// (README needs to be updated). I included both to show the behavior that I experience when trying different things. I am also not using an emulator. I have an iPad 2 running iOS 9.3.5 and it has Adobe Reader, so it should be able to open the PDF. I also tried today on an iPad Air running iOS 10.3.2. Neither device works calling showOpenWithDialog. If I call open() and view the document, I can then click the arrow in the upper right corner and open it in Adobe Reader. One other interesting scenario I discovered... if I execute my function twice (by tapping my download button twice), and THEN rotate the iPad, the pop up shows in the bottom right of the screen. From there, if I click the Adobe Reader app then my app crashes. |
I will double check later as currently don't have MacBook. I tested this functionality on iphone5 and iphone6s it was working fine. One more suggestion. Do not use tmp fs. download() {
const url = 'http://www.example.com/file.pdf';
fileTransfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
} This is an example from ionic native docs. If you don't use ionic, replace |
Thanks for the help, I really appreciate it. I tried changing the location of the file and it did not have any effect. I had been using examples from the Cordova documentation and didn't realize I could download a file by specifying cordova.file.dataDirectory so that's nice to know in any case. As an experiment, I changed our app's target device family to include iPhone, and installed the app on my iPhone 5 (iOS 10.2.1). The call to showOpenWithDialog worked on my iPhone and I was able to open the file in Adobe Reader without a problem. So my guess at this point is that it's related to where the dialog box is rendered on screen and for iPads it is rendered off screen (which could explain why I see the dialog box randomly when I download it twice and rotate the iPad). |
I ran the app on my iPad with it plugged into my Mac to see the logs in the Xcode debugger. Here's what it printed (6 variations of this message):
Also I switched back to Cordova 6.5.0 since 7.0.1 was just released and hasn't been tested in the wild as much. |
@agilethomas , did you have any luck with this? This seems to be the exact issue I'm having currently... console says file opened successful, but no openwithdialog appears. standard open works fine.. However, opening twice and changing orientation on my ipad mini does nothing, and I don't have an iphone to test whether it shows on there. |
@andycaoz4 Yes - we did get it working. We plan to create a pull request for our fix but until then you can try out our fork: https://github.com/agilethomas/cordova-plugin-file-opener2 |
@agilethomas , got your branch and got everything compiled, but still no go. I see the comments "use options.rect paramenter to FileOpener2.open...". does this mean we're extending the .open() method and we're passing options.rect into open() as parameter in js instead of using showOpenWithDialog? Can you post up the correct js call you ended up doing for the openwith dialog box to work? Thanks. |
We did add a parameter in the JS call so we can position the openWith dialog box. Here's our JS call:
|
@agilethomas YES! Thank you for this snippet! It is now working on iOS iPad Mini for me. Please enjoy an imaginary beer from me to you! |
@agilethomas Any idea why the preview dialog doesn't appear on iOS 10.3 but works fine on iPad iOS 9 and 11 ..? @andycaoz4 doest it works fine for you on iPad iOS 11 |
@fpoirier1 I don't know... pretty sure it worked on iOS 10.x but I've since upgraded to iOS 11 so I don't have an iPad to test it on right now. Will have to find one to test on now though. |
I have this problem with an iPad Pro (ios 11.3). showOpenWithDialog is not working, however on my iphone everything works as it should. The Code-Snippet from @agilethomas makes no difference. It seems that the dialog opens somewhere you can't see it. |
@sfrimont I have the same problem with iPad Pro (ios 11.0.2) |
Hi. I have been using this plugin for a couple of years already, and suddenly it stopped working. Anyway, after doing so the error has disappeared. Though the workaround was forked by @agilethomas, is a PR still possible at this time? Thanks! |
Oh, I take it back. The dialog does pop up, but after selecting "Copy to Adobe Acrobat", nothing happens. "file opened successfully" console logs but after that nothing. Current specs Just upgraded to iOS 11.3. New update (as of 2018/5/8): After using @agilethomas's fork, the dialog pops out. (Again, thank you. I just used So I just did the same approach that was done for Android: Copy the file to a temporary folder (eg. cordova.file.tempDirectory) and pass that file path to the showOpenWithDialog function. I am not sure if everyone else had a similar root problem, but I just wished that I have thought of implementing the Android way with iOS in the first place and saving myself a couple of days worth of time. Not so clean code:
|
hi @agilethomas, thanks for raising this issue. There is currently another open PR which I believe was trying to address the same problem: #72. If this was merged would it fix your issue too? |
closing this as a duplicate of #67. There will be another release in the near future with a feature to position the dialog for iOS |
I'm trying to use the showOpenWithDialog feature, but I can't get it to work for some reason.
I'm downloading the file successfully, because I can use fileopener2.open() and it will open the PDF in a new window. I can also see the request successfully completing on the server side when I call the showOpenWithDialog function, and the success callback is also getting called. But nothing happens on the UI.
I found this recent issue that seemed related:
#132
I don't use Xcode that much (we build our app using cordova's command line), but I was able to find the "Auto layout" setting in the MainViewController.xib file under Classes/ in the File Navigator. That's the only .xib file I found. That setting is already unchecked in the File Inspector. I tried checking it and rebuilding it, but that did not have any effect.
I also found another "Auto layout" setting in the Resources > CDVLaunchScreen.storyboard, but unchecking Auto Layout did not have any effect.
I've upgraded Cordova to 7.0.1 and am using XCode 8.2.1. This is for an iPad app only. It's minimum target is iOS 9.0 and I'm running 9.3.5 on an iPad 2.
Any ideas?
Thanks!
The text was updated successfully, but these errors were encountered: