针对如何在app中打开第三方的应用这个问题,本文将以打开新浪微博为例做详细讲解。
1.配置所要打开的应用
在Native/plugins文件夹下新建所要打开的应用的文件夹,其中有配置文件plugin.xml。
以新浪微博为例:
plugin.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="com.justep.cordova.plugin.sinaWeibo" version="5.3.0">
<name>新浪微博</name>
<description>新浪微博</description>
<license>MIT</license>
<keywords>cordova,sina</keywords>
<!--require cordova version -->
<engines>
<engine name="cordova" version=">=3.5.0" />
</engines>
<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<allow-intent href="sinaweibo://*" />
</config-file>
<config-file platform="ios" target="*-Info.plist" parent="LSApplicationQueriesSchemes">
<array>
<string>sinaweibo</string>
</array>
</config-file>
</platform>
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<allow-intent href="sinaweibo://*" />
</config-file>
</platform>
</plugin>
配置文件中主要要点为配置要打开应用的intent和scheme(都可上网查到),下图已标示出:
2.在自己的app中引入所要打开应用
在自己的app页面中引入,例:
require("cordova!com.justep.cordova.plugin.sinaWeibo");
然后打开地址”sinaweibo://userinfo?uid=3444956000″
例:
<a href="sinaweibo://userinfo?uid=3444956000">直接打开</a>
点击即可打开微博(其中uid为想要打开的用户uid)


评一波