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

bug: Camera.getPhoto can't reject promise when close image picker by swipe down. #3008

Closed
1 of 4 tasks
taxibae opened this issue May 29, 2020 · 3 comments · Fixed by #3010
Closed
1 of 4 tasks

bug: Camera.getPhoto can't reject promise when close image picker by swipe down. #3008

taxibae opened this issue May 29, 2020 · 3 comments · Fixed by #3010

Comments

@taxibae
Copy link

taxibae commented May 29, 2020

Bug Report

Capacitor Version

npx cap doctor output:
Latest Dependencies:
@capacitor/cli: 2.1.1
@capacitor/core: 2.1.1
@capacitor/android: 2.1.1
@capacitor/electron: 2.1.1
@capacitor/ios: 2.1.1

Installed Dependencies:
@capacitor/android not installed
@capacitor/electron not installed
@capacitor/cli 2.1.1
@capacitor/core 2.1.1
@capacitor/ios 2.1.1

Found 0 Capacitor plugins for ios:

Affected Platform(s)

  • Android
  • iOS
  • Electron
  • Web

Current Behavior

  1. Call Camera.getPhoto with "source: CameraSource.Photos" option.
  2. Present ImagePicker
  3. Close ImagePicker by swipe down.
  4. Camera.getPhoto return anything.

Expected Behavior

Camera.getPhoto should reject promise with error message :"User cancelled photos app"

Sample Code or Sample Application Repo

Ionic-angular project
bitbucket repo

Reproduction Steps

  1. Run the app on iOS 13.4.1
  2. click "Open PhotoLibrary" button
  3. close picker modal by swipe down

See 30-second Video

Other Technical Details

npm --version output: 6.13.4
node --version output: v12.16.1
pod --version output (iOS issues only): 1.8.4

Other Information

I need exception handling code for when the user closes the ImagePicker using the close button, or when the modal is swiped down to close.
The close button worked as intended, but not for swipe down actions.
As a test, I replaced line 199 of the Camera.swift :

public func popoverPresentationControllerDidDismissPopover(_ popoverPresentationController: UIPopoverPresentationController) {
  self.call?.error("User cancelled photos app")
}

with

public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
  self.call?.error("User cancelled photos app")
}

to see it work as intended.
But I don't know much about iOS, so I don't know what side effects this code will cause.
If there are no problems, can I create a pull request?

@jcesarmobile
Copy link
Member

Hi, thanks for the pointers, I've sent the PR already.

popoverPresentationControllerDidDismissPopover is still needed for iOS 11-12, presentationControllerDidDismiss is new on iOS 13.

@taxibae
Copy link
Author

taxibae commented May 29, 2020

Thanks for your explanation!

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants