Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a Nativescript Android app from a link in a email

I would like to open my android application from a link in an email. Searching through Stackoverflow it looks like this can be achieved using a '' which points to a url I control. I'm a little confused how to use this though in the case of an android app built with Nativescript. Is just adding a url that I own with a specific data path the only thing that needs to be done? In which case that brings up an app selector dialog. Can a certain event be fired off when the application is opened this way? Thanks for the help. Below is a sample of what it looks like I need to do.

    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER" />

        <!-- Custom Path data -->
        <data
            android:host="www.some.company.com"
            android:path="/something"
            android:scheme="http"/>
    </intent-filter>
like image 473
Stavros_S Avatar asked Jul 18 '16 20:07

Stavros_S


People also ask

Can a developer build an app using NativeScript?

NativeScript is a free and open-source framework for developing mobile applications. It is used to build truly native mobile apps using JavaScript. You can easily develop a native UI and higher-performance apps for your iOS and Android platforms using Angular skills.

How do I change the name of my NativeScript app?

To edit the Package Name and the Application Id, modify the package. json of your app and set the nativescript.id key. You may need to delete platforms/android and rebuild using the CLI command ns prepare android . Read more about "ApplicationId versus PackageName".


1 Answers

Add this to you main.ts

import app = require("application");
import platform = require("platform");

declare var android: any;

if(!!app.android){
    app.android.on(app.AndroidApplication.activityResumedEvent, function (args) { 
        console.log("Event: " + args.eventName + ", Activity: " + args.activity); 
        console.log(new String(args.activity.getIntent().getAction()).valueOf(), new String(android.content.Intent.ACTION_VIEW).valueOf());
        if(new String(args.activity.getIntent().getAction()).valueOf() ==  new String(android.content.Intent.ACTION_VIEW).valueOf()){
            console.log(args.activity.getIntent().getData()); 
        }
    });
}
like image 60
KielSoft Avatar answered Oct 20 '22 00:10

KielSoft