mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
feat(deeplinks): Add Ionic Deeplinks Plugin
This commit is contained in:
parent
4875f66b7a
commit
c93cbed9d2
@ -24,6 +24,7 @@ import {Clipboard} from './plugins/clipboard';
|
||||
import {Contacts} from './plugins/contacts';
|
||||
import {DatePicker} from './plugins/datepicker';
|
||||
import {DBMeter} from './plugins/dbmeter';
|
||||
import {Deeplinks} from './plugins/deeplinks';
|
||||
import {Device} from './plugins/device';
|
||||
import {DeviceAccounts} from './plugins/deviceaccounts';
|
||||
import {DeviceMotion} from './plugins/devicemotion';
|
||||
@ -85,6 +86,7 @@ export {
|
||||
Contacts,
|
||||
DatePicker,
|
||||
DBMeter,
|
||||
Deeplinks,
|
||||
Device,
|
||||
DeviceAccounts,
|
||||
DeviceMotion,
|
||||
@ -148,6 +150,7 @@ window['IonicNative'] = {
|
||||
Contacts: Contacts,
|
||||
DatePicker: DatePicker,
|
||||
DBMeter: DBMeter,
|
||||
Deeplinks: Deeplinks,
|
||||
Device: Device,
|
||||
DeviceAccounts: DeviceAccounts,
|
||||
DeviceMotion: DeviceMotion,
|
||||
|
74
src/plugins/deeplinks.ts
Normal file
74
src/plugins/deeplinks.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
||||
export interface DeeplinkMatch {
|
||||
/**
|
||||
* The route info for the matched route
|
||||
*/
|
||||
routeInfo: any;
|
||||
|
||||
/**
|
||||
* The arguments passed to the route through GET params along with
|
||||
* any internal native data available as "extras" at the time
|
||||
* the route was matched (for example, Facebook sometimes adds extra data)
|
||||
*/
|
||||
args: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Ionic Deeplinks
|
||||
* @description This plugin handles deeplinks on iOS and Android for both custom URL scheme links
|
||||
* and Universal App Links.
|
||||
*
|
||||
* @usage
|
||||
* ```ts
|
||||
* import {IonicDeeplinks} from 'ionic-native';
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
plugin: 'ionic-plugin-deeplinks',
|
||||
pluginRef: 'IonicDeeplink',
|
||||
repo: 'https://github.com/driftyo/ionic-plugin-deeplinks',
|
||||
platforms: ['iOS', 'Android']
|
||||
})
|
||||
export class Deeplinks {
|
||||
|
||||
/**
|
||||
* Define a set of paths to match against incoming deeplinks.
|
||||
*
|
||||
* @param {paths} Define a set of paths to match against incoming 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.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true
|
||||
})
|
||||
static route(paths): Observable<DeeplinkMatch> {return; }
|
||||
|
||||
/**
|
||||
*
|
||||
* This is a convenience version of `route` that takes a reference to a NavController
|
||||
* from Ionic 2, or a custom class that conforms to this protocol:
|
||||
*
|
||||
* NavController.push = function(View, Params){}
|
||||
*
|
||||
* This handler will automatically navigate when a route matches. If you need finer-grained
|
||||
* control over the behavior of a matching deeplink, use the plain `route` method.
|
||||
*
|
||||
* @param {paths} Define a set of paths to match against incoming 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.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true
|
||||
})
|
||||
static routeWithNavController(navController, paths): Observable<DeeplinkMatch> {return; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user