🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

ionic-plugin-deeplinks

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ionic-plugin-deeplinks - npm Package Compare versions

Comparing version

to
1.0.3

2

package.json
{
"name": "ionic-plugin-deeplinks",
"version": "1.0.2",
"version": "1.0.3",
"cordova": {

@@ -5,0 +5,0 @@ "id": "ionic-plugin-deeplinks",

@@ -32,5 +32,7 @@ Ionic Deeplinks Plugin

#### Ionic/Angular 2
*note: make sure to call IonicDeeplink from a platform.ready or `deviceready` event*
Using [Ionic Native](https://github.com/driftyco/ionic-native):
Using [Ionic Native](https://github.com/driftyco/ionic-native) (available in 1.2.4 or greater):

@@ -60,17 +62,71 @@ ```javascript

'/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);
});
// Note: routeWithNavController also returns an observable you can also subscribe to for success/error in matching as in the first example
```
Coming soon: VanillaJS and Ionic 1/Angular 1 instructions
#### Ionic/Angular 1
For Ionic 1 and Angular 1 apps using Ionic Native, there are many ways we can handle deeplinks. However,
we need to make sure we set up a history stack for the user, we can't navigate directly to our page
because Ionic 1's navigation system won't properly build the navigation stack (to show a back button, for example).
This is all fine because deeplinks should provide the user with a designed experience for what the back button
should do, as we are putting them deep into the app and need to provide a natural way back to the main flow:
(See a simple [demo](https://github.com/driftyco/ionic1-deeplinks-demo) of v1 deeplinking).
```javascript
angular.module('myApp', ['ionic', 'ionic.native'])
.run(['$ionicPlatform', '$cordovaDeeplinks', '$state', '$timeout', function($ionicPlatform, $cordovaDeeplinks, $state, $timeout) {
$ionicPlatform.ready(function() {
// Note: route's first argument can take any kind of object as its data,
// and will send along the matching object if the route matches the deeplink
$cordovaDeeplinks.route({
'/product/:productId': {
target: 'product',
parent: 'products'
}
}).subscribe(function(match) {
// One of our routes matched, we will quickly navigate to our parent
// view to give the user a natural back button flow
$timeout(function() {
$state.go(match.$route.parent, match.$args);
// Finally, we will navigate to the deeplink page. Now the user has
// the 'product' view visibile, and the back button goes back to the
// 'products' view.
$timeout(function() {
$state.go(match.$route.target, match.$args);
}, 800);
}, 100); // Timeouts can be tweaked to customize the feel of the deeplink
}, function(nomatch) {
console.warn('No match', nomatch);
});
});
}])
```
#### Non-Ionic/angular
Ionic Native works with non-Ionic/Angular projects and can be accessed at `window.IonicNative` if imported.
If you don't want to use Ionic Native, the plugin is available on `window.IonicDeeplink` with a similar API minus the observable callback:
```javascript
window.addEventListener('deviceready', function() {
IonicDeeplink.route({
'/product/:productId': {
target: 'product',
parent: 'products'
}
}, function(match) {
}, function(nomatch) {
});
})
```
## iOS Configuration

@@ -77,0 +133,0 @@