如何解决如何捕获/跟踪应用程序快捷方式图标点击事件?
我有一个 ionic 3 应用。它具有深层链接和推送通知。我怎么知道应用是通过点击应用图标打开还是通过任何其他外部链接打开?
解决方法
你没有解释你是如何实现深层链接的(展示你的代码),但我假设你使用了这个插件:https://ionicframework.com/docs/native/deeplinks
当您实施深层链接时,会在通过链接打开应用程序时触发一个事件:
this.deeplinks.route({
'/about-us': AboutPage
}).subscribe(match => {
// match.$route - the matched route
// match.$args - args passed in the link
// Here do something
},nomatch => {
console.error('Got a deeplink that didn\'t match',nomatch);
});
现在,如果您想知道以后如何“记住”应用程序是通过链接打开的,只需将该值放入服务中,因为服务有一个实例,在所有应用程序执行过程中都保持不变,并且存储在服务中的任何变量都可以在任何地方使用,因此:
.subscribe(match => {
// match.$route - the matched route
// match.$args - args passed in the link
myAppService.openByLink = true;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。