From 6982a2d35f26165475b2542325f090148f661ce0 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Tue, 18 Oct 2016 12:21:43 -0500 Subject: [PATCH] chore(deeplinks): Updated Deeplinks docs --- src/plugins/deeplinks.ts | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/plugins/deeplinks.ts b/src/plugins/deeplinks.ts index 3b85f36c..103474ae 100644 --- a/src/plugins/deeplinks.ts +++ b/src/plugins/deeplinks.ts @@ -28,9 +28,35 @@ export interface DeeplinkMatch { * * @usage * ```typescript - * import { IonicDeeplinks } from 'ionic-native'; + * import { Deeplinks } from 'ionic-native'; * + * Deeplinks.route({ + '/about-us': AboutPage, + '/universal-links-test': AboutPage, + '/products/:productId': ProductPage + }).subscribe((match) => { + // match.$route - the route we matched, which is the matched entry from the arguments to route() + // match.$args - the args passed in the link + // match.$link - the full link data + console.log('Successfully matched route', match); + }, (nomatch) => { + // nomatch.$link - the full link data + console.error('Got a deeplink that didn\'t match', nomatch); + }); * ``` + * + * Alternatively, if you're using Ionic 2, there's a convenience method that takes a reference to a `NavController` and handles + * the actual navigation for you: + * + * ```typescript + * Deeplinks.routeWithNavController(this.navController, { + '/about-us': AboutPage, + '/products/:productId': ProductPage + }); + * ``` + * + * See the [Ionic 2 Deeplinks Demo](https://github.com/driftyco/ionic2-deeplinks-demo/blob/master/app/app.ts) for an example of how to + * retrieve the `NavController` reference at runtime. */ @Plugin({ name: 'Deeplinks', @@ -49,8 +75,8 @@ export class Deeplinks { * paths takes an object of the form { 'path': data }. If a deeplink * matches the path, the resulting path-data pair will be returned in the * promise result which you can then use to navigate in the app as you see fit. - * @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and - * is rejected if a deeplink comes through that does not match a given path. + * @returns {Observable} Returns an Observable that is called each time a deeplink comes through, and + * errors if a deeplink comes through that does not match a given path. */ @Cordova({ observable: true @@ -72,8 +98,8 @@ export class Deeplinks { * matches the path, the resulting path-data pair will be returned in the * promise result which you can then use to navigate in the app as you see fit. * - * @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and - * is rejected if a deeplink comes through that does not match a given path. + * @returns {Observable} Returns an Observable that resolves each time a deeplink comes through, and + * errors if a deeplink comes through that does not match a given path. */ @Cordova({ observable: true