ionic-plugin-deeplinks
Advanced tools
Comparing version
{ | ||
"name": "ionic-plugin-deeplinks", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"cordova": { | ||
@@ -5,0 +5,0 @@ "id": "ionic-plugin-deeplinks", |
@@ -12,3 +12,3 @@ Ionic Deeplinks Plugin | ||
Since Custom URL schemes are no longer supported on iOS >= 9.2 iOS, you'll need to [configure Universal Links](#universal-links) | ||
Since Custom URL schemes are no longer supported on iOS >= 9.2 iOS, you'll need to [configure Universal Links](#ios-configuration) | ||
@@ -33,38 +33,44 @@ *Note: this plugin may clash with existing Custom URL Scheme and Universal Links Plugins. Please let | ||
*note: make sure to call IonicDeeplink from a platform.ready or `deviceready` event* | ||
Using [Ionic Native](https://github.com/driftyco/ionic-native): | ||
```typescript | ||
import {IonicDeeplink} from 'ionic-native'; | ||
import {Deeplinks} from 'ionic-native'; | ||
IonicDeeplink.route({ | ||
Deeplinks.route({ | ||
'/about-us': AboutPage, | ||
'/universal-links-test': AboutPage, | ||
'/products/:productId': ProductPage | ||
}, (routeInfo, args) => { | ||
console.log('Successfully matched route', routeInfo, args); | ||
}, (routeInfo) => { | ||
console.error('Got a deeplink that didn\'t match', routeInfo); | ||
}).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); | ||
}); | ||
``` | ||
If you're using Ionic 2, there is a convenience method to route automatically: | ||
If you're using Ionic 2, there is a convenience method to route automatically (see the simple [Ionic 2 Deeplinks](https://github.com/driftyco/ionic2-deeplinks-demo/blob/master/app/app.ts) demo for an example): | ||
```typescript | ||
IonicDeeplink.routeWithNavController(this.navChild, { | ||
Deeplinks.routeWithNavController(this.navController, { | ||
'/about-us': AboutPage, | ||
'/universal-links-test': AboutPage, | ||
'/products/:productId': ProductPage | ||
}), (routeInfo, args) => { | ||
// Optional callback | ||
// Successful match, feel free to do more here or just let it slide | ||
console.log('Successfully routed', routeInfo, args); | ||
}, (routeInfo) => { | ||
// Handle a deeplink that didn't match, if you fancy | ||
console.error('Unable to route', routeInfo); | ||
}).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); | ||
}); | ||
``` | ||
[](#universal-links) | ||
Coming soon: VanillaJS and Ionic 1/Angular 1 instructions | ||
## iOS Configuration | ||
@@ -71,0 +77,0 @@ |
20865
2.68%87
7.41%