Guide on how to navigate within an app by clicking on a link from an email

Is there a way to launch my Android application (Nativescript) from a link in an email that says "Click here to reset password"?

For example, the email contains a link like this:

When I click on this link from my mobile browser, I want the app to open to the resetPassword component.

I have tried the following code in my AndroidManifest.xml, but it only works for the URL :

        <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>

I have also added the route in routing.ts like this:

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

However, clicking on the link does not open the specified component. Is there any solution for this?

Answer №1

In cases where the path contains dynamic parameters, it is recommended to utilize the android:pathPattern attribute.

For instance:

<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="example.domain.com" android:path="/v1/userProfile/.*"></data> 
 </intent-filter>

It is essential to specify this URL pattern so that Android knows to launch your app upon matching the specified criteria. Angular does not play a role in this scenario. To route to a specific component based on the URL pattern, manual handling is required.

To achieve this functionality, consider installing the custom plugin and extract the URL used to launch the app within the app component, triggering navigation in your router as needed.

import { Component, OnInit } from "@angular/core";
import { handleOpenURL, AppURL } from 'custom-plugin-name';

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

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Develop a query builder in TypeORM where the source table (FROM) is a join table

I am currently working on translating this SQL query into TypeORM using the QueryBuilder: SELECT user_places.user_id, place.mpath FROM public.user_root_places_place user_places INNER JOIN public.place place ON place.id = user_places.place_id The ...

What is the best way to set HTML content in the ElementRef's nativeElement?

I am trying to use a directive to set the content of an HTML element. export class AdvertisementDirective { constructor(el: ElementRef) { el.nativeElement.style.background = 'yellow'; el.nativeElement.content = '<p>Hello Wo ...

Using TypeScript to narrow down types within mapped types

Can you create a mapped type based on the property type? For example, if I want to map all properties with type String to Foo and all other types to Bar. Can this be done like this: type MappedType<T> = { [P in keyof T]: T[P] === String ? Foo : B ...

"Is There a Specific Order for Organizing Angular Router

Could you please clarify the difference between these two code snippets? const routes: Routes = [ { path: '', canActivate: [AuthGuard], component: MainComponent, children: [ { path: '', component: DashboardComponent }, ...

Using Typescript to define custom PopperComponent props in Material UI

I'm currently utilizing the Material UI autocomplete feature in my React and Typescript application. I'm looking to create a custom popper component to ensure that the popper is full-width. Here's how I can achieve this: const CustomPopper ...

Angular is unable to modify the value of 'name' since it is either a constant or a property that cannot be modified

I am encountering an error that says "Cannot assign to 'name' because it is a constant or a read-only property" when trying to send data to the API. Does anyone know how I can solve this issue? Thank you. onSubmit() { const name = this.backU ...

Tips for safely storing data in local storage using Angular 5

How can I securely store data in local storage, such as encrypting and decrypting the local storage data to prevent manipulation by other users? If it's not possible with local storage, what are alternative methods for client-side data storage? I&apo ...

Managing numerous post requests with Angular

Dealing with a large form containing HTML input elements, I have implemented a functionality where a POST request is made to a WebAPI whenever there is a change in the input value. Sometimes, multiple POST requests are triggered within seconds, causing da ...

Enforcement of static methods in Typescript abstract classes is not mandatory

In my TypeScript code, I have a simple structure defined: abstract class Config { readonly NAME: string; readonly TITLE: string; static CoreInterface: () => any } class Test implements Config { readonly NAME: string; readonly TITL ...

If a router contains a parameter, this can cause the component to be unable to locate the style of index.html

Using Angular version 2.0.0-rc.4 Encountering an issue with the router when a parameter is present, for example localhost:4200/component/parameter. This results in an error message stating Failed to load resource: the server responded with a status of 404 ...

Voice recognition feature in the latest version of Chrome on Android devices

When using a PC with Chrome 25 (non beta), I see a microphone icon that prompts for input when clicked. After speaking, my alert call is successfully executed. However, on a Galaxy Note smartphone with Chrome 25 and an Android 4.04 operating system, the sa ...

Triggering two function calls upon submission and then waiting for the useEffect hook to execute

Currently, I am facing a challenge with form validation that needs to be triggered on submit. The issue arises as some of the validation logic is located in a separate child component and is triggered through a useEffect dependency from the parent componen ...

Building state from multiple child components in Next.js/React: Best Practices

To better illustrate this concept, I suggest checking out this codesandbox link. This is a follow-up to my previous question on Stack Overflow, which can provide additional context. Currently, when interacting with the child elements (such as inputs), th ...

Encountering a new challenge in Angular: The error "InvalidPipeArgument: '' for pipe 'AsyncPipe'

Whenever I try to fetch data from the server, these errors keep popping up. This code was written by someone else and I would like to improve upon it. Could anyone suggest the best approach to handle this situation? Are there any coding patterns that sho ...

How can we optimize component loading in react-virtualized using asynchronous methods?

In my component, I have implemented a react-virtualized masonry grid like this: const MasonrySubmissionRender = (media: InputProps) => { function cellRenderer({ index, key, parent, style }: MasonryCellProps) { //const size = (media.submiss ...

Encountering a NULL POINTER EXCEPTION with an array adapter in a listview on an Android device

When passing data from a second main view to a first main view in Android using startActivityforResult(), I encountered an issue with displaying the data on a listview. Despite successfully receiving the string back, I kept getting a nullpointer exception. ...

Implementing a default child route in Nativescript

Is there a way for me to access /account/dashboard while the router is set to '/account'? My current routes do not seem to be working properly. The AccountPage component is loading instead of the AccountDashboardPage. export const routes = [ ...

What could be causing the issue with my Angular integration with Jira Issue Collector to not function properly?

Looking to link the Jira issue collector with an Angular application I attempted something along the lines of Component.ts import { Component, OnInit } from '@angular/core'; import * as jQuery from 'jquery'; declare global { inter ...

What is the best way to extract and retrieve the most recent data from an XmlHttpRequest?

Currently, I am using a web service that returns an SseEmitter to program a loading bar. The method to receive it looks like this: static async synchronize(component: Vue) { let xhr = new XMLHttpRequest(); xhr.open('PATCH', 'myUrl.co ...

Having difficulty transmitting data through SocketIO in NodeJS

My current project involves sending streams of data through SocketIO sockets. I'm working on a Node TS application that will handle large files, so the standard Buffer object won't cut it. Here's the code I have so far: Client Side socket. ...