H5实现链接格式如下
<a href="[scheme]://[host]/[path]?[query]"> 唤起应用 </a>
各个项目含义如下所示:
scheme:唤起协议 ※详细后述
host: 唤起指定host
path: 协议路径※没有也可以
query: 一些参数※没有也可以
APP实现
协议假设为:example://com.example.demo/app?name=zhangsan
AndroidManifest中添加配置
<activity android:name=".SchemeActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="example"
android:host="com.example.demo"
android:path="/app"/>
</intent-filter>
</activity>
DATA标签中匹配原则如下:
android:scheme : 唤起协议
android:host : 唤起host,只有置顶的host才可被唤起
android:pathPrefix : 唤起的路径,对路径进一步的过滤
客户端获取参数的值
Uri uri = this.getIntent().getData();
String scheme=uri.getScheme();
String host=uri.getHost();
String path=uri.getPath();
String name=uri.getQueryParameter("name");
注意事项
无论是在哪个平台的客户端Android/IOS,在微信的平台上访问都有一个问题,那就是无法启动客户端,这是微信为了安全性考虑的限制,android这边屏蔽schema协议,除非公司是微信的伙伴加入了白名单才能
网友评论