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

WebIntent bug #564

Closed
todamach opened this issue Sep 21, 2016 · 1 comment
Closed

WebIntent bug #564

todamach opened this issue Sep 21, 2016 · 1 comment

Comments

@todamach
Copy link

I'm trying to open .apk using webintent plugin on Ionic2 typescript project. I'm using Ionic native.

official webintent docs shows this example:

    window.plugins.webintent.startActivity({
      action: window.plugins.webintent.ACTION_VIEW,
      url: theFile.toURL(),
      type: 'application/vnd.android.package-archive'
    },
    function() {},
    function() {
      alert('Failed to open URL via Android Intent.');
      console.log("Failed to open URL via Android Intent. URL: " + theFile.fullPath)
    }
    );

options takes 3 parameters: action, url and type.

When I try to use it in project it only accepts two: action and url.

      WebIntent.startActivity({
      action: WebIntent.ACTION_VIEW,
      url: this.uri,
    }).then(() => {
      alert("Success. URL: " + this.uri);
    },
    () => {
      alert("Failed to open URL via Android Intent. URL: " + this.uri);
      console.log("Failed to open URL via Android Intent. URL: " + this.uri)
    });

If i use it like that it tries to open apk as pdf file and fails. If i add 3rd parameter it says, that it only accepts two parameters (basically).

If I go to node_modules/ionic-native/dist/plugins/webintend.d.ts and change

    static startActivity(options: {
        action: any;
        url: string;
    }):

to

    static startActivity(options: {
        action: any;
        url: string;
        type: string;
    }):

it successfully opens the .apk and tries to install it.

I'm new to ionic, so I might be missing something, but maybe it might help someone else, since I googled, but didn't find any ionic2 "open .apk file" examples.

@mlynch mlynch closed this as completed in a0b6b10 Sep 23, 2016
@mlynch
Copy link
Collaborator

mlynch commented Sep 23, 2016

Thanks @todamach, just added type as an optional param to the master branch

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

No branches or pull requests

2 participants