Skip to content

Commit c93cbed

Browse files
committed
feat(deeplinks): Add Ionic Deeplinks Plugin
1 parent 4875f66 commit c93cbed

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {Clipboard} from './plugins/clipboard';
2424
import {Contacts} from './plugins/contacts';
2525
import {DatePicker} from './plugins/datepicker';
2626
import {DBMeter} from './plugins/dbmeter';
27+
import {Deeplinks} from './plugins/deeplinks';
2728
import {Device} from './plugins/device';
2829
import {DeviceAccounts} from './plugins/deviceaccounts';
2930
import {DeviceMotion} from './plugins/devicemotion';
@@ -85,6 +86,7 @@ export {
8586
Contacts,
8687
DatePicker,
8788
DBMeter,
89+
Deeplinks,
8890
Device,
8991
DeviceAccounts,
9092
DeviceMotion,
@@ -148,6 +150,7 @@ window['IonicNative'] = {
148150
Contacts: Contacts,
149151
DatePicker: DatePicker,
150152
DBMeter: DBMeter,
153+
Deeplinks: Deeplinks,
151154
Device: Device,
152155
DeviceAccounts: DeviceAccounts,
153156
DeviceMotion: DeviceMotion,

src/plugins/deeplinks.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import {Plugin, Cordova} from './plugin';
2+
import {Observable} from 'rxjs/Observable';
3+
4+
export interface DeeplinkMatch {
5+
/**
6+
* The route info for the matched route
7+
*/
8+
routeInfo: any;
9+
10+
/**
11+
* The arguments passed to the route through GET params along with
12+
* any internal native data available as "extras" at the time
13+
* the route was matched (for example, Facebook sometimes adds extra data)
14+
*/
15+
args: any;
16+
}
17+
18+
/**
19+
* @name Ionic Deeplinks
20+
* @description This plugin handles deeplinks on iOS and Android for both custom URL scheme links
21+
* and Universal App Links.
22+
*
23+
* @usage
24+
* ```ts
25+
* import {IonicDeeplinks} from 'ionic-native';
26+
*
27+
* ```
28+
*/
29+
@Plugin({
30+
plugin: 'ionic-plugin-deeplinks',
31+
pluginRef: 'IonicDeeplink',
32+
repo: 'https://github.com/driftyo/ionic-plugin-deeplinks',
33+
platforms: ['iOS', 'Android']
34+
})
35+
export class Deeplinks {
36+
37+
/**
38+
* Define a set of paths to match against incoming deeplinks.
39+
*
40+
* @param {paths} Define a set of paths to match against incoming deeplinks.
41+
* paths takes an object of the form { 'path': data }. If a deeplink
42+
* matches the path, the resulting path-data pair will be returned in the
43+
* promise result which you can then use to navigate in the app as you see fit.
44+
* @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and
45+
* is rejected if a deeplink comes through that does not match a given path.
46+
*/
47+
@Cordova({
48+
observable: true
49+
})
50+
static route(paths): Observable<DeeplinkMatch> {return; }
51+
52+
/**
53+
*
54+
* This is a convenience version of `route` that takes a reference to a NavController
55+
* from Ionic 2, or a custom class that conforms to this protocol:
56+
*
57+
* NavController.push = function(View, Params){}
58+
*
59+
* This handler will automatically navigate when a route matches. If you need finer-grained
60+
* control over the behavior of a matching deeplink, use the plain `route` method.
61+
*
62+
* @param {paths} Define a set of paths to match against incoming deeplinks.
63+
* paths takes an object of the form { 'path': data }. If a deeplink
64+
* matches the path, the resulting path-data pair will be returned in the
65+
* promise result which you can then use to navigate in the app as you see fit.
66+
*
67+
* @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and
68+
* is rejected if a deeplink comes through that does not match a given path.
69+
*/
70+
@Cordova({
71+
observable: true
72+
})
73+
static routeWithNavController(navController, paths): Observable<DeeplinkMatch> {return; }
74+
}

0 commit comments

Comments
 (0)