Skip to content

Commit 965901b

Browse files
committed
Add: Deep Link API
1 parent 45e377b commit 965901b

File tree

14 files changed

+93
-8
lines changed

14 files changed

+93
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# dependencies
22
/node_modules
33
.DS_Store
4-
test.html
4+
test.html
5+
./dist

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Android JS 2.0
44
[Android JS](https://android-js.github.io) framework lets you write android applications
5-
using JavaScript, HTML and CSS or React Native with [Node.js](https://nodejs.org/) support. It is based on [Node.js](https://nodejs.org/).
5+
using JavaScript, HTML and CSS or `React Native` with [Node.js](https://nodejs.org/) support. It is based on [Node.js](https://nodejs.org/).
66
It allows you to write fully featured android application in `node js` and provide you environment to use any `npm` package in your android app (i.e. SocketIO, fs, etc..)
77

88
## Installation

build/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Android JS 2.0
44
[Android JS](https://android-js.github.io) framework lets you write android applications
5-
using JavaScript, HTML and CSS or React Native with [Node.js](https://nodejs.org/) support. It is based on [Node.js](https://nodejs.org/).
5+
using JavaScript, HTML and CSS or `React Native` with [Node.js](https://nodejs.org/) support. It is based on [Node.js](https://nodejs.org/).
66
It allows you to write fully featured android application in `node js` and provide you environment to use any `npm` package in your android app (i.e. SocketIO, fs, etc..)
77

88
## Installation

build/lib/androidjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/react_native/androidjs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ var toast = require("./api/toast");
66
var wifi = require("./api/wifi");
77
var call = require("./api/call");
88
var contact = require("./api/contact");
9+
var deeplink = require("./api/deeplink");
910
module.exports = {
1011
notification: notification,
1112
hotspot: hotspot,
1213
toast: toast,
1314
wifi: wifi,
1415
call: call,
1516
contact: contact,
17+
deeplink: deeplink,
1618
getPath: app.getPath,
1719
loadUrl: app.loadURL,
1820
reload: app.reload
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
var NativeModules = require('react-native').NativeModules;
3+
var deeplink = /** @class */ (function () {
4+
function deeplink() {
5+
}
6+
deeplink.prototype.getLink = function () {
7+
return NativeModules.DeepLink.getDeepLink();
8+
};
9+
return deeplink;
10+
}());
11+
module.exports = new deeplink();

docs/deeplink.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# DeepLink API
2+
`app.deeplink` is the instance of `DeepLink API`, which provide functions to enable `DeepLink` to your app content.
3+
4+
`NOTE : In order to enable Deep Link to your app, you have to do all the following configurations.`
5+
6+
## `First Update Your Package.JSON`
7+
In order to enable `Deep Link` to your app, you'll have to define array of objects with following attributes in `package.json` file of your app
8+
- You need to define `deep-link` attribute in `package.json` which is array of `objects` of `scheme` and `host`
9+
- You can define as many `scheme` and `host` you want
10+
11+
- `scheme`
12+
- it is protocol on which you want to enable deep link your app
13+
- `host`
14+
- it is particular host on which you want to deep link your app
15+
16+
## Example Configuration
17+
```json
18+
{
19+
"deep-link":[
20+
{
21+
"scheme" : "http",
22+
"host" : "android-js.github.io"
23+
},
24+
{
25+
"scheme" : "https",
26+
"host" : "android-js.github.io"
27+
}
28+
]
29+
}
30+
```
31+
whenever user click on `defined links or hosts`, your app will be `listed as suggestion` to `open` that `link in your app`
32+
# Access Link In Your App
33+
## Methods
34+
35+
#### `app.deeplink.getLink()`
36+
Returns a `link` on which `user clicked` to `open` that in `your app`
37+
38+
`NOTE: returns link if available otherwise -1`
39+
An example of above code:
40+
```js
41+
// In views of your app
42+
43+
let link = app.deeplink.getLink();
44+
if(link != '-1') {
45+
app.loadURL(link);
46+
}
47+
```
48+

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
- [Toast API](toast_api.md)
2121
- [Call API](call_api.md)
2222
- [Contact API](contact_api.md)
23+
- [DeepLink API](deeplink_api.md)
2324
- [App](app.md)

src/build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ files = [
1515
['./src/react_native/androidjs/api/toast.ts', './dist/react_native/api'],
1616
['./src/react_native/androidjs/api/wifi.ts', './dist/react_native/api'],
1717
['./src/react_native/androidjs/api/contact.ts', './dist/react_native/api'],
18+
['./src/react_native/androidjs/api/deeplink.ts', './dist/react_native/api'],
1819
['./src/react_native/androidjs/androidjs.ts', './dist/react_native'],
1920
['./src/react_native/androidjs/api/notification.ts', './build/lib/react_native/api'],
2021
['./src/react_native/androidjs/api/app.ts', './build/lib/react_native/api'],
@@ -23,6 +24,7 @@ files = [
2324
['./src/react_native/androidjs/api/toast.ts', './build/lib/react_native/api'],
2425
['./src/react_native/androidjs/api/wifi.ts', './build/lib/react_native/api'],
2526
['./src/react_native/androidjs/api/contact.ts', './build/lib/react_native/api'],
27+
['./src/react_native/androidjs/api/deeplink.ts', './build/lib/react_native/api'],
2628
['./src/react_native/androidjs/androidjs.ts', './build/lib/react_native']
2729
]
2830

src/react_native/androidjs/androidjs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import toast = require('./api/toast');
55
import wifi = require('./api/wifi');
66
import call = require('./api/call');
77
import contact = require('./api/contact');
8+
import deeplink = require('./api/deeplink');
89

910
export = {
1011
notification,
@@ -13,6 +14,7 @@ export = {
1314
wifi,
1415
call,
1516
contact,
17+
deeplink,
1618
getPath: app.getPath,
1719
loadUrl: app.loadURL,
1820
reload: app.reload

0 commit comments

Comments
 (0)