|
| 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