Feel free to donate
Or donate Bitcoins: bitcoin:3NKtxw1SRYgess5ev4Ri54GekoAgkR213D
Also via greenaddress
Usage
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:
;;
And for pure NativeScript:
var handleOpenURL = handleOpenURL; ;
Or as TypeScript:
; handleOpenURL;
Note: see
demo
app for sample usage. Start by adding handleOpenURL in app main!
Installation
$ 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
Android
Replace myapp with your desired scheme and set launchMode to singleTask
...
For example:
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.
iOS
CFBundleURLTypes CFBundleURLName com.yourcompany.myapp CFBundleURLSchemes myapp
FAQ
Callback handling
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!
Webpack
TypeScript Config
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"
]