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

Safari-view-controller : Only resolve one result #1619

Closed
tgensol opened this issue May 30, 2017 · 3 comments
Closed

Safari-view-controller : Only resolve one result #1619

tgensol opened this issue May 30, 2017 · 3 comments
Assignees
Labels

Comments

@tgensol
Copy link

tgensol commented May 30, 2017

I'm submitting a ... (check one with "x")
[X ] bug report
[ ] feature request

Current behavior:
The show function only returns one result.event (opened)

Expected behavior:
Maybe an Observable would to a better job than a promise ?

Related code:

 this.safariViewController.isAvailable()
        .then((available: boolean) => {
          if (available) {
            this.safariViewController.show({
              url: 'http://www.google.com',
            })
              .then((result: any) => {
// only one result will be resolved
})
@danielsogl
Copy link
Owner

Hey @tgensol,
as you can see from the plugin repo page, the function wants one parameter (options) and can return a success or error callback.

  show: function (options, onSuccess, onError) {
    options = options || {};
    if (!options.hasOwnProperty('animated')) {
      options.animated = true;
    }
    exec(onSuccess, onError, "SafariViewController", "show", [options]);
  },

https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller/blob/master/www/SafariViewController.js#L12

@tgensol
Copy link
Author

tgensol commented May 31, 2017

Hey @danielsogl ,

I know, and this is where the ionic-native plugin is not working as expected,

https://ionicframework.com/docs/native/safari-view-controller/

The promise only resolved once (the result.opened), and then, it doesn't resolve again for "loaded" or closed. The doc is maybe wrong, or... ?

@ihadeed
Copy link
Collaborator

ihadeed commented Jun 1, 2017

Yeah, show should return an Observable instead of a Promise. I didn't notice that the callback is multi-purpose...

@ihadeed ihadeed added the bug label Jun 1, 2017
@ihadeed ihadeed self-assigned this Jun 1, 2017
ihadeed added a commit that referenced this issue Jul 10, 2017
BREAKING CHANGE: `show` method now returns an Observable

closes #1619
BuddyLReno pushed a commit to BuddyLReno/ionic-native that referenced this issue Aug 28, 2017
BREAKING CHANGE: `show` method now returns an Observable

closes danielsogl#1619
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

3 participants