Feel free to donate
Or donate Bitcoins: bitcoin:3NKtxw1SRYgess5ev4Ri54GekoAgkR213DAlso via greenaddress
Just add App links to your app, see iOS and Android instructions below, and register a handler for the URL data.
See this example for Angular:
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);
});
}
}
And for pure NativeScript:
var handleOpenURL = require("nativescript-urlhandler").handleOpenURL;
handleOpenURL(function(appURL) {
console.log('Got the following appURL', appURL);
});
Or as TypeScript:
import { handleOpenURL, AppURL } from 'nativescript-urlhandler';
handleOpenURL((appURL: AppURL) => {
console.log('Got the following appURL', appURL);
});
Note: see
demo
app for sample usage. Start by adding handleOpenURL in app main!
$ tns plugin add nativescript-urlhandler
Or if you want to use the development version (nightly build), which maybe not stable!:
$ tns plugin add nativescript-urlhandler@next
Replace myapp with your desired scheme and set launchMode to singleTask
<activity android:name="com.tns.NativeScriptActivity" ... android:launchMode="singleTask"...>
...
<intent-filter>
<data android:scheme="myapp" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
For example:
<activity android:name="com.tns.NativeScriptApplication" android:label="@string/app_name" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="myapp" android:host="__PACKAGE__" />
</intent-filter>
</activity>
The android:launchMode="singleTask" tells the Android operating system to launch the app with a new instance of the activity, or use an existing one. Without this your app will launch multiple instances of itself which is no good.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.yourcompany.myapp</string>
</dict>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
</dict>
</array>
The "handleOpenURL" callback must be called before application initialization, otherwise you'll see this error in the console:
No callback provided. Please ensure that you called "handleOpenURL" during application init!
If your Webpack Build is failing, try adapting your tsconfig to this:
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"lib": [
"es6",
"dom",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
},
"exclude": [
"node_modules",
"platforms",
"**/*.aot.ts"
]
This lib also support HTTPS intent, you can define a host for it. Here is an example on Android with both custom & HTTPS scheme :
<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="my-app" />
</intent-filter>
<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="https" android:host="my-website.com" />
</intent-filter>
Let's suppose your put a <a href="https://my-website.com/check-our-app">Check our mobile app</a>
link on your website to open your mobile app.Because https intent is also linked to the mobile browser, when user will tap on the link, a popup will appears to let the user choose between the browser and your mobile app to open this link.
In the other hand, if you setup a android:scheme="my-app"
that only your app react to, putting a <a href="my-app://check-our-app">Check our mobile app</a>
link like this on your website will avoid this popup and open your mobile app directly.
一、初始化流程 在开始分析启动流程之前,我们先从混合开发流程入手,大致分两步。 1.继承ReactActivity,并完成相关初始化工作。 public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler { private ReactRootView mReactRootView;
React Native问题记录 背景:使用React Native来开发一个日报App(现仅有android端),所以下面的记录都是在弄android端遇到的问题与相应的处理 0. 搭建环境 搭建环境的指导可参考 https://reactnative.cn/docs/0.43/getting-started/ 1. 找不到index.android bundle 错误信息:unable to
项目中经常会遇到web和原生之间的交互,在没有使用桥接的情况下,我们主要是在webView代理方法里面处理,如下: - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NativeScript 可以使用 Javascript,CSS, XML 创建真正的 Native 跨平台应用,支持 iOS Android,NativeScript 将您的跨平台代码翻译成目标平台的代码。 UI 使用 XML 描述,CSS 样式,在编译时将 UI 转化成本地原生代码,最终得到正在的 Native 原生应用。 Telerik 公开了用于创建安卓、iOS和Windows Unive
NativeScript Command-Line Interface The NativeScript CLI lets you create, build, and deploy NativeScript-based apps on iOS and Android devices. Get it using: npm install -g nativescript What is Native
NativeScript-Snackbar �� �� �� NativeScript plugin for Material Design SnackBar component. Installation: NativeScript 7+:tns plugin add @nstudio/nativescript-snackbar NativeScript version prior to 7:t
Nativescript-Ripple This plugin aims to bring a native (or close to native) ripple implementation on Android and iOS. The android version uses a RippleDrawable and conserves the previous background, a
NativeScript-FloatingActionButton NativeScript plugin for Material Design Floating Action Button UI component. Installation Nativescript 7+: ns plugin add @nstudio/nativescript-floatingactionbutton Na
NativeScript CardView A NativeScript plugin to provide an XML widget to implement the Material Design CardView component. Installation NativeScript 7+: ns plugin add @nstudio/nativescript-cardview Nat
This project has moved: This project is now being maintained here: https://github.com/nativescript-community/ui-mapboxas it's become clear contrary to what I thought, I don't actually have enough time
Nativescript Hijri plugin This plugin is inspired by https://github.com/arabiaweather/hijri-date Nativescript-hijri Hijri plugin allow you to convert gregorian date to islamic hijri date. Installation