最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - PhoneGap - Open external application - Stack Overflow

programmeradmin4浏览0评论

I am developing a PhoneGap App, All what I need is to open an external application.

e.g. my app namespace is com.demo.app1 and I need to open the com.demo.app2 application, Is this feasible ?

  • I am using PhoneGap 3.3
  • I found that there is many versions of the WebIntent plugin
  • An example may help :)

Thanks

I am developing a PhoneGap App, All what I need is to open an external application.

e.g. my app namespace is com.demo.app1 and I need to open the com.demo.app2 application, Is this feasible ?

  • I am using PhoneGap 3.3
  • I found that there is many versions of the WebIntent plugin
  • An example may help :)

Thanks

Share Improve this question edited Mar 4, 2014 at 9:42 amd asked Mar 4, 2014 at 9:36 amdamd 21.5k6 gold badges53 silver badges71 bronze badges 2
  • 1 for android you have the webintent plugin. for ios I have no idea. – QuickFix Commented Mar 4, 2014 at 9:51
  • how can I use it to open an app by package name ? – amd Commented Mar 4, 2014 at 9:51
Add a comment  | 

4 Answers 4

Reset to default 7

You can crea a plugin with this java code:

Intent LaunchIntent = this.cordova.getActivity().getPackageManager().getLaunchIntentForPackage("com.demo.app2");
this.cordova.getActivity().startActivity(LaunchIntent);

or try any of this 2 plugins for launching apps

https://github.com/lampaa/org.apache.cordova.startapp

https://github.com/dmedvinsky/cordova-startapp

Finally found my old code of when I was using webintent :

   CDV.WEBINTENT.launchActivity("com.demo.app1",
            function() {
                console.log("Activity started");
            },
            function() {
                console.log("Error starting activity");
            }
    );

There are two different gits for webintent referenced in phonegap build for phonegap 3.x, no idea what the differences are (and the first one is the one I was using) :

  • https://github.com/InQBarna/WebIntent.git
  • https://github.com/Tunts/WebIntent/
  • https://github.com/acen99/WebIntent/

And an other usefull plugin is the webavailability plugin that lets you know if the other app is installed before you try to launch it : https://github.com/ohh2ahh/AppAvailability.git

I stopped using webintent because I needed to be able to switch to an app if it was already started and not relanch it.

EDIT: oops again, launchactivity was a function I added to the plugin... will check later how I was doing before this.

In iOS to open any application you need to know which URLs schemes supported by this app.

For example, you can open email-writer by url like "mailto:[email protected]". But the thing is in application you can declare your own scheme. For example in App1 you can declare scheme like "my-app1-scheme". And in your second app you will need to open URL "my-app1-scheme://" and your App1 will be opened.

And I just found this plugin that allows you to do this in simpler way: https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin

Finally, I implemented my own plugin that offer the following:

  • getUniqueDeviceId (return a unique device ID)
  • openApp (open an installed app, and fallback to the store if available)
  • openStore (open the store on a specific app)

http://ahmad-moussawi.github.io/pgutils/

Please feel free to contribute or suggest any other feature.

发布评论

评论列表(0)

  1. 暂无评论