flutter网页唤醒APP

这里只介绍安卓的端的用法
配置文件需要更改
通过host和scheme就能和app匹配

// AndroidManifest.xml
// activity 下添加
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:host="splash" android:scheme="vchao" />
            </intent-filter>

WEB端通过链接就能打开了

<a href="vchao://splash/?arg0=marc&arg1=xie">直接打开</a>
<a href="vchao://splash/?path=home&arg1=xie">打开首页</a>
 <a href="vchao://splash/?path=anecdotal&arg1=xie">打开朋友圈</a>

参数处理
需要下载依赖 uni_links: ^0.2.0
在底部渲染tab导航的页面注册监听方法,来接收跳转链接

  initState() {
    super.initState();
    initUniLinks();
  }

  Future<Null> initUniLinks() async {
    print('------获取参数--------');
    // Platform messages may fail, so we use a try/catch PlatformException.
      _sub = getLinksStream().listen((String link) {
        Map params = Utils.formateUrl(link);
        String path = params['path'];
        print('path');
        print(path);
        print(context);
        if(path.isNotEmpty){
          RouterUtil.push(context,path,'');
        }
        print('---213---');
        print(link);
      // Parse the link and warn the user, if it is not correct
    }, onError: (err) {
      // Handle exception by warning the user their action did not succeed
    });
  }

根据路径就能跳转到不同的页面了

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 移动互联时代,很多互联网服务都会同时具备网站以及移动客户端,很多人认为APP的能帮助建立更稳固的用户关系,于是经常...
    zyl04401阅读 44,077评论 17 72
  • 移动互联网时代,“用户增长”成为每个公司关注的重点话题。为了将更多用户引导到客户端内,产品经理会习惯性地在网页的各...
    宇晓阅读 21,855评论 4 20
  • uni-app跨平台框架官方教程 链接:https://ke.qq.com/course/343370 一、框架简...
    Neyo_凉阅读 36,343评论 0 43
  • 在这个流量为王的互联网背景下,移动端的H5页面显然在导流上承担着重要作用,在H5页面上,我们对引流的需求有两种: ...
    明日幻想阅读 2,000评论 0 4
  • https://v.qq.com/x/page/d015782luyv.html 1.“日常生活”教育为什么很重要...
    0e8416fcddaf阅读 134评论 0 0