1 | import { Observable } from 'rxjs/Observable';
|
2 | export interface DeeplinkMatch {
|
3 | /**
|
4 | * The route info for the matched route
|
5 | */
|
6 | $route: any;
|
7 | /**
|
8 | * Any arguments passed either through route parameters or GET parameters
|
9 | */
|
10 | $args: any;
|
11 | /**
|
12 | * The deeplink object processed from the plugin, along with any
|
13 | * any internal native data available as "extras" at the time
|
14 | * the route was matched (for example, Facebook sometimes adds extra data)
|
15 | */
|
16 | $link: any;
|
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 | * ```typescript
|
25 | * import { Deeplinks } from 'ionic-native';
|
26 | *
|
27 | * Deeplinks.route({
|
28 | '/about-us': AboutPage,
|
29 | '/universal-links-test': AboutPage,
|
30 | '/products/:productId': ProductPage
|
31 | }).subscribe((match) => {
|
32 | // match.$route - the route we matched, which is the matched entry from the arguments to route()
|
33 | // match.$args - the args passed in the link
|
34 | // match.$link - the full link data
|
35 | console.log('Successfully matched route', match);
|
36 | }, (nomatch) => {
|
37 | // nomatch.$link - the full link data
|
38 | console.error('Got a deeplink that didn\'t match', nomatch);
|
39 | });
|
40 | * ```
|
41 | *
|
42 | * Alternatively, if you're using Ionic 2, there's a convenience method that takes a reference to a `NavController` and handles
|
43 | * the actual navigation for you:
|
44 | *
|
45 | * ```typescript
|
46 | * Deeplinks.routeWithNavController(this.navController, {
|
47 | '/about-us': AboutPage,
|
48 | '/products/:productId': ProductPage
|
49 | }).subscribe((match) => {
|
50 | // match.$route - the route we matched, which is the matched entry from the arguments to route()
|
51 | // match.$args - the args passed in the link
|
52 | // match.$link - the full link data
|
53 | console.log('Successfully matched route', match);
|
54 | }, (nomatch) => {
|
55 | // nomatch.$link - the full link data
|
56 | console.error('Got a deeplink that didn\'t match', nomatch);
|
57 | });
|
58 | * ```
|
59 | *
|
60 | * See the [Ionic 2 Deeplinks Demo](https://github.com/driftyco/ionic2-deeplinks-demo/blob/master/app/app.ts) for an example of how to
|
61 | * retrieve the `NavController` reference at runtime.
|
62 | *
|
63 | * @interfaces
|
64 | * DeeplinkMatch
|
65 | */
|
66 | export declare class Deeplinks {
|
67 | /**
|
68 | * Define a set of paths to match against incoming deeplinks.
|
69 | *
|
70 | * @param {paths} Define a set of paths to match against incoming deeplinks.
|
71 | * paths takes an object of the form { 'path': data }. If a deeplink
|
72 | * matches the path, the resulting path-data pair will be returned in the
|
73 | * promise result which you can then use to navigate in the app as you see fit.
|
74 | * @returns {Observable<DeeplinkMatch>} Returns an Observable that is called each time a deeplink comes through, and
|
75 | * errors if a deeplink comes through that does not match a given path.
|
76 | */
|
77 | static route(paths: any): Observable<DeeplinkMatch>;
|
78 | /**
|
79 | *
|
80 | * This is a convenience version of `route` that takes a reference to a NavController
|
81 | * from Ionic 2, or a custom class that conforms to this protocol:
|
82 | *
|
83 | * NavController.push = function(View, Params){}
|
84 | *
|
85 | * This handler will automatically navigate when a route matches. If you need finer-grained
|
86 | * control over the behavior of a matching deeplink, use the plain `route` method.
|
87 | *
|
88 | * @param {paths} Define a set of paths to match against incoming deeplinks.
|
89 | * paths takes an object of the form { 'path': data }. If a deeplink
|
90 | * matches the path, the resulting path-data pair will be returned in the
|
91 | * promise result which you can then use to navigate in the app as you see fit.
|
92 | *
|
93 | * @returns {Observable<DeeplinkMatch>} Returns an Observable that resolves each time a deeplink comes through, and
|
94 | * errors if a deeplink comes through that does not match a given path.
|
95 | */
|
96 | static routeWithNavController(navController: any, paths: any): Observable<DeeplinkMatch>;
|
97 | }
|