Skip to content
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

Open and Save image on iOS13 - does not return to correct view #294

Open
drewwynne0 opened this issue May 12, 2020 · 9 comments
Open

Open and Save image on iOS13 - does not return to correct view #294

drewwynne0 opened this issue May 12, 2020 · 9 comments
Labels

Comments

@drewwynne0
Copy link

Expected Behaviour

When saving an image on iOS13, return to the previous view as it does in iOS12.

Actual Behaviour

When saving an image on iOS13, it returns to the incorrect view. This works fine in iOS12.
Tried latest beta 13.5, still does not work.
If I open an image, select the share options and Save Image, the preview is closed, but it returns to the cordova core view, not the last view. If the last view was the inAppBrowser, the core view is displayed instead, but you cannot interact with the page until you hide the inappbrowser.

Reproduce Scenario (including but not limited to)

If the last view was the inAppBrowser, the core view is displayed instead, but you cannot interact with the page until you hide the inappbrowser.

Steps to Reproduce

open an image, select the share options and Save Image

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

iOS13

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

n/a

Cordova CLI info

cordova info

Here is the output:

[email protected] with:
[email protected]
[email protected]
[email protected]
[email protected]

Environment:
OS: darwin
Node: v10.16.3
npm: 6.9.0

...

iOS platform:
Xcode 11.4.1

...

cordova-plugin-file 6.0.2 “File”
cordova-plugin-file-opener2 3.0.1 “File Opener2”
cordova-plugin-inappbrowser 3.2.0 “InAppBrowser”
cordova-plugin-ionic-webview 4.2.1 “cordova-plugin-ionic-webview”

Plugin version

cordova plugin version | grep cordova-plugin-file-opener2

Here is the output:

cordova-plugin-file-opener2 3.0.1 “File Opener2”

Sample Code that illustrates the problem

This opens the image, but is not the cause.

cordova.plugins.fileOpener2.open(
file,
fileType,
{
error : function(e){
console.log('open error');
console.log(e);
},
success : function(e){
console.log('open success');
console.log(e);
}
}
);

Logs taken while reproducing problem

No logs. This SO thread may help though:
https://stackoverflow.com/questions/56903030/ios-13-uiactivityviewcontroller-automatically-present-previous-vc-after-image-sa

@pwlin
Copy link
Owner

pwlin commented May 13, 2020

@drewwynne0 Can you upload a basic example? I will test it in xcode to see if I can fix the issue.

@pwlin pwlin added the ios label May 13, 2020
@pwlin
Copy link
Owner

pwlin commented May 14, 2020

@drewwynne0 I have tested this with xcode and iOS 13 simulator, it opens the dialog correctly and after saving the image, it returns to the app itself. Can you please show a screenshot of what is it showing on your device?

@drewwynne0
Copy link
Author

@pwlin Thank you for testing. I will put together an example for you over the coming days. I think the key part is that the inappbrowser needs to be in use.
Launch App
Launch Browser (webkit) and leave active
Open Image (triggered from browser using messages api to pass url and download, then open which all works great)
Save Image - This returns back to App Primary screen from step 1, not the browser from step 2, but the active screen is still the browser so touch events don't work on the App Primary Screen.
When I hide the browser (even though not visible) the App screen becomes active and the touch works again.
When I show the browser again, I am back to where expected after Saving the Image.

I have the index just as a white screen so nothing really to show in the screenshot, but in the example I will leave it as stock so you will return to the Cordova Default index page you get when you launch the app, just with no touch events working because they are still tied to the browser.

@pwlin
Copy link
Owner

pwlin commented May 16, 2020

@drewwynne0 here is a test project for ios

  • Clone that project
  • Add ios platform: cordova platform add ios
  • Run the project: cordova run
  • Alternate image text
  • Can you test your problem here?

@drewwynne0
Copy link
Author

@pwlin thanks for the example - made things easier! I have added a new branch - https://github.com/pwlin/example-fileopener2-ios/tree/%23294 - If you launch the app - open the image - then click back - you will see the browser where I have loaded codepen.
If you then quit and relaunch the app (or run ref.hide() in safari console) - open the image again and click Save Image in the share options, the preview closes and returns to the original view with none of the actions clickable (until you run ref.hide();) - my expectation was that this should return to the browser like the back button does. Thank you for your help!

@pwlin
Copy link
Owner

pwlin commented May 23, 2020

https://i.imgur.com/mdlbpxv.png
I think you should not call those 2 functions one after another like that, you need to call file-opener2 plugin from inside your inappbrowser plugin. Here is an example: https://github.com/dpa99c/cordova-plugin-inappbrowser-test/

Try to run that project and look in the code for webkit.messageHandlers.cordova_iab.postMessage

https://i.imgur.com/L5S8CU6.png

I think that is how you call other plugins in inappbrowser plugin.

Here is the original pull request with more discussions and example: https://github.com/apache/cordova-plugin-inappbrowser/pull/362

@drewwynne0
Copy link
Author

@pwlin I do currently use the messaging system like you suggest to trigger the download of the file from the web server to the app, then use this plugin to open from the local file copy.

I was going to setup that whole mechanism through codepen, but I was actually able to replicate the issue without having to go that far.

My understanding is that the way views are handled natively has slightly changed with iOS13. Here is a post and thread discussing it on SO - https://stackoverflow.com/a/57798040

I also checked on 13.5 and still an issue.

Do you want me to add the messaging part into codepen? The result is the same but if it will help you diagnose further I am happy to update the branch to include it.

@drewwynne0
Copy link
Author

@pwlin Do you think that article is related to this issue? Have you had chance to investigate further? Let me know if you want me to add the messaging.

@pwlin
Copy link
Owner

pwlin commented Jun 2, 2020

@drewwynne0 I am sorry I have not got time to really look into it.

Last time I have checked the code in your branch was not clear. Please create a clear use-case example in master branch without the reference to codepen or anything external. You can commit your external pages into a sub-folder.

Also as i mentioned before calling 2 functions one after another will not work, so try to commit anything you have into master branch so I can see exactly how are you using webkit.messageHandlers.cordova_iab.postMessage. Currently, it's not clear how are you using the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants