当我单击电子邮件中的链接时,如何在应用程序中进行路由 [英] How to routing in a app when I click a link from email

查看:127
本文介绍了当我单击电子邮件中的链接时,如何在应用程序中进行路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过电子邮件中的链接打开Application Android(本机)中的组件,即单击此处重置密码

I want to open my component in Application Android (Nativescript) from a link in email, that is Click here to reset password

我在电子邮件中有这样的链接:

I have a link like this in email:

http://secsystem.domain.tk/v1/resetPassword/11E8FC9

因此,当我从移动浏览器中单击链接时,我需要在组件resetPassword中启动应用.

So when I click the link from my mobile browser I need the app Launched in component resetPassword.

我使用以下代码:

AndroidManifest.xml

AndroidManifest.xml

        <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:scheme="http" android:host="secsystem.domain.tk" android:path="/v1/resetPassword"></data> 
        </intent-filter>

此代码仅在以下URL中有效: http://secsystem.domain.tk/v1/resetPassword

This code works good only in this url: http://secsystem.domain.tk/v1/resetPassword

我想使用以下URL: http://secsystem.domain.tk/v1 /resetPassword/11E8FC9

I want to work in this url: http://secsystem.domain.tk/v1/resetPassword/11E8FC9

在routing.ts中,我编写了这段代码:

In routing.ts I write this code:

{ path: 'v1/resetPassword/:id', component: ResetPassIdComponent },

我想在单击链接时打开此组件.

I want to open this component when I click in link.

对此有什么解决办法吗?

Is there any solution for this?

推荐答案

当路径具有动态参数时,应使用android:pathPattern.

You should use android:pathPattern when the path has dynamic parameter.

示例

<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:scheme="http" android:host="secsystem.domain.tk" android:path="/v1/resetPassword/.*"></data> 
 </intent-filter>

到目前为止,所有有关使Android理解的是,当此特定的URL模式匹配时,它必须打开此应用程序. Angular与这里无关.如果要在使用此URL模式打开应用程序时导航到特定组件,则必须手动处理它.

So far this is all about making Android understand it has to open this app when this particular URL pattern is matched. Angular has nothing to do here. If you want to navigate to particular component when app is opened with this URL pattern, then you must handle it manually.

安装 nativescript-urlhandler 插件并查询用于在其中打开应用程序的URL应用程序组件,并相应地在路由器中启动导航.

Install nativescript-urlhandler plugin and query the URL that was used to open the app in the app component and initiate navigation in your router accordingly.

import { Component, OnInit } from "@angular/core";
import { handleOpenURL, AppURL } from 'nativescript-urlhandler';

@Component({
  selector: "gr-main",
  template: "<page-router-outlet></page-router-outlet>"
})
export class AppComponent {
    constructor() {
    } 

    ngOnInit(){
        handleOpenURL((appURL: AppURL) => {
            console.log('Got the following appURL', appURL);
        });
     }
}

这篇关于当我单击电子邮件中的链接时,如何在应用程序中进行路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆