Coder Social home page Coder Social logo

ionic-team / ionic-plugin-deeplinks Goto Github PK

View Code? Open in Web Editor NEW
333.0 18.0 218.0 135 KB

Handle deeplinks into your Ionic/Cordova apps from Universal Links, App Links, and Custom URL schemes. For those using Ionic 2, there are some nice goodies that make life easier.

License: Other

Objective-C 35.82% JavaScript 31.17% Java 33.01%

ionic-plugin-deeplinks's Introduction

Community Maintained

This plugin is being maintained by the Ionic community. Interested in helping? Message max on ionic worldwide slack.

Another great solution for deep links for Ionic is the Branch Metrics plugin: https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking

If you used to handle URI schemes with the help of this plugin and have migrated to Branch Metrics, you can make use of a plugin such as https://github.com/EddyVerbruggen/Custom-URL-scheme to facilitate custom URL schemes.

Ionic Deeplinks Plugin

This plugin makes it easy to respond to deeplinks through custom URL schemes and Universal/App Links on iOS and Android.

For example, you can have your app open through a link to https://yoursite.com/product/cool-beans and then navigate to display the Cool Beans in your app (cool beans!).

Additionally, on Android iOS, your app can be opened through a custom URL scheme, like coolbeans://product/cool-beans.

Since Custom URL scheme behavior has changed quite a bit in iOS 9.2 for the case where the app isn't installed, you'll want to start using Universal Links as it's clear custom URL schemes are on the way out.

Note: this plugin may clash with existing Custom URL Scheme and Universal Links Plugins. Please let us know if you encounter compatibility issues. Also, try removing them and using this one on its own.

Thank you to the Cordova Universal Links Plugin and the Custom URL Scheme plugin that this plugin is inspired and borrows from.

Installation

cordova plugin add ionic-plugin-deeplinks
--variable URL_SCHEME=myapp --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=example.com
--variable ANDROID_PATH_PREFIX=/

Fill in the appropriate values as shown below:

  • URL_SCHEME - the custom URL scheme you'd like to use for your app. This lets your app respond to links like myapp://blah
  • DEEPLINK_SCHEME - the scheme to use for universal/app links. Defaults to 'https' in 1.0.13. 99% of the time you'll use https here as iOS and Android require SSL for app links domains.
  • DEEPLINK_HOST - the host that will respond to deeplinks. For example, if we want example.com/product/cool-beans to open in our app, we'd use example.com here.
  • ANDROID_PATH_PREFIX - (optional): specify which path prefix our Android app should open from more info

(New in 1.0.13): If you'd like to support multiple hosts for Android, you can also set the variables DEEPLINK_2_SCHEME, DEEPLINK_2_HOST, ANDROID_2_PATH_PREFIX and optionally substitue 2 with 3, 4, and 5 to set more.

Handling Deeplinks in JavaScript

Ionic/Angular 2

note: make sure to call IonicDeeplink from a platform.ready or deviceready event

Using Ionic Native (available in 1.2.4 or greater):

import { Platform, NavController } from 'ionic-angular';
import { Deeplinks } from '@ionic-native/deeplinks/ngx';

export class MyApp {
  constructor(
    protected platform: Platform
    , protected navController: NavController
    , protected deeplinks: Deeplinks
    ) {
    this.platform.ready().then(() => {
      this.deeplinks.route({
        '/about-us': HomePage,
        '/products/:productId': HelpPage
      }).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 returns an observable from Ionic Native so it *must* be subscribed to first in order to trigger.

If you're using Ionic 2, there is a convenience method to route automatically (see the simple Ionic 2 Deeplinks demo for an example):

import { Platform, NavController } from 'ionic-angular';
import { Deeplinks } from '@ionic-native/deeplinks/ngx';

export class MyApp {
  constructor(
    protected platform: Platform
    , protected navController: NavController
    , protected deeplinks: Deeplinks
    ) {
    this.platform.ready().then(() => {
      this.deeplinks.routeWithNavController(this.navController, {
        '/about-us': HomePage,
        '/products/:productId': HelpPage
      }).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 returns an observable from Ionic Native so it *must* be subscribed to first in order to trigger.

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 of v1 deeplinking).

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:

window.addEventListener('deviceready', function() {
  IonicDeeplink.route({
    '/product/:productId': {
      target: 'product',
      parent: 'products'
    }
  }, function(match) {
  }, function(nomatch) {
  });
})

iOS Configuration

As of iOS 9.2, Universal Links must be enabled in order to deep link to your app. Custom URL schemes are no longer supported.

Follow the official Universal Links guide on the Apple Developer docs to set up your domain to allow Universal Links.

How to set up top-level domains (TLD's)

Set up Associated Domains

First you must enable the Associated Domains capability in your provisioning profile. After that you must enable it in the Xcode project, too. For automated builds you can do it easily by adding this to your config.xml.

<config-file target="*-Debug.plist" parent="com.apple.developer.associated-domains">
    <array>
        <string>applinks:example.org</string>
    </array>
</config-file>

<config-file target="*-Release.plist" parent="com.apple.developer.associated-domains">
    <array>
        <string>applinks:example.org</string>
    </array>
</config-file>

Instead of applinks only you could use <string>webcredentials:example.org</string> or <string>activitycontinuation:example.org</string>, too.

Set up Apple App Site Association (AASA)

Your website (i.e. example.org) must provide this both files.

  • /apple-app-site-association
  • /.well-known/apple-app-site-association

The content should contain your app.

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "1A234BCD56.org.example",
        "paths": [
          "NOT \/api\/*",
          "NOT \/",
          "*"
        ]
      }
    ]
  }
}

This means that all your requests - except /api and / - will be redirected to your app. Please replace 1A234BCD56 with your TEAM ID and org.example with your Bundle-ID. (the id="" of your <widget />)

Android Configuration

Android supports Custom URL Scheme links, and as of Android 6.0 supports a similar feature to iOS' Universal Links called App Links.

Follow the App Links documentation on Declaring Website Associations to enable your domain to deeplink to your Android app.

To prevent Android from creating multiple app instances when opening deeplinks, you can add the following preference in Cordova config.xml file:

 <preference name="AndroidLaunchMode" value="singleTask" />

How to set up top-level domains (TLD's)

Your website (i.e. example.org) must provide this file.

  • /.well-known/assetlinks.json

The content should contain your app.

[
  {
    "relation": [
      "delegate_permission\/common.handle_all_urls"
    ],
    "target": {
      "namespace": "android_app",
      "package_name": "org.example",
      "sha256_cert_fingerprints": [
        "12:A3:BC:D4:56:E7:89:F0:12:34:5A:B6:78:90:C1:23:45:DE:67:FA:89:01:2B:C3:45:67:8D:9E:0F:1A:2B:C3"
      ]
    }
  }
]

Replace org.example with your app package. (the id="" of your <widget />) The fingerprints you can get via $ keytool -list -v -keystore my-release-key.keystore. You can test it via https://developers.google.com/digital-asset-links/tools/generator.

ionic-plugin-deeplinks's People

Contributors

acran avatar bayruns avatar bramzor avatar christiaanscheermeijer avatar chrisweight avatar danielsogl avatar elylucas avatar farmertjes avatar fdezromero avatar ihadeed avatar lindon88 avatar marutifh avatar masimplo avatar mlynch avatar mmodzelewski avatar mvidailhet avatar nvazquezg avatar patrickbussmann avatar peterpeterparker avatar samueltthomas avatar stalniy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ionic-plugin-deeplinks's Issues

match.$route undefined

Hi,

When using Deeplinks.route with a route containing a parameter, on success routing, I get an undefined match.$route (match itself is defined but $route is missing).

Here my code in my app.ts:

ngAfterViewInit() {
    this.platform.ready().then(() => {
        // Convenience to route with a given nav
        Deeplinks.route({
            '/myroute/:myId': MyPage
        }).subscribe((match:DeeplinkMatch) => {

            // ----> Here, match.$route == undefined
            alert('Successfully matched route' + JSON.stringify(match.$route));

        }, (nomatch) => {
            console.error('Got a deeplink that didn\'t match', nomatch);
        });
    });
}

keep getting plugin not installed

Hello,
so i keep getting the following error, even though i have installed the plugin and when i browse to the url it does open the app but doesnt navigate to the page.

5     830621   log      DEVICE READY FIRED AFTER, 3344, ms
0     192741   warn     Native: tried calling Deeplinks.routeWithNavController, but the Deeplinks plugin is not installed.
1     192743   warn     Install the Deeplinks plugin: 'ionic plugin add ionic-plugin-deeplinks'
2     192743   warn     Unmatched Route, plugin_not_installed
$ ionic plugin
com.verso.cordova.clipboard 0.1.0 "Clipboard"
cordova-plugin-camera 2.3.0 "Camera"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-crop 0.1.0 "CropPlugin"
cordova-plugin-device 1.1.3 "Device"
cordova-plugin-geolocation 2.4.0 "Geolocation"
cordova-plugin-inappbrowser 1.5.0 "InAppBrowser"
cordova-plugin-splashscreen 4.0.0 "Splashscreen"
cordova-plugin-statusbar 2.2.0 "StatusBar"
cordova-plugin-whitelist 1.3.0 "Whitelist"
cordova-plugin-x-socialsharing 5.1.3 "SocialSharing"
cordova.plugins.diagnostic 3.2.2 "Diagnostic"
ionic-plugin-deeplinks 1.0.8 "Ionic Deeplink Plugin"
ionic-plugin-deploy 0.6.5 "IonicDeploy"
ionic-plugin-keyboard 2.2.1 "Keyboard"
onesignal-cordova-plugin 2.0.6 "OneSignal Push Notifications"
plugin.google.maps 1.3.9 "phonegap-googlemaps-plugin"

Deep linking is not working

Deep linking works in whatsapp, hangouts, mail.
But in Facebook in android , the links gives the 400 error and the app is not opening
And also the twitter in IOS , the links gives the 404 error and the app is not opening.

Could you please help me in this and thank in advance for helping !

Default Params

Hi! Great plugin!

Is it possible to create roots with predefined params? Such as:

Deeplinks.routeWithNavController(this.nav, {
                 '/page0': {page :Main,  var:0}
                 '/page1': {Page: Main, var:1}
});

Best Regards,
Artur

My app never routes to the defined page

My app (Ionic2) and I tested the demo (ionic2-deeplinks-demo) don't route using params.
example:

myapp://alert/42
myapp://products/42 (for demo)

I got this error message

Unmatched Route
Object
$link: Object
host: "products"
path: "/1"
queryString: ""
scheme: "my app
url: "myapp://products/1"

They are working perfectly with a simple URL
example:

myapp://about-us

wildcard hosts

Hello,
So i set host as *.domain.com and then call abc.domain.com the open apps url of host does not have abc., its just simple domain.com. I need to track the subdomain any idea?

Deeplinks.routeWithNavController doesn't work without subscribe

Hey,

Maybe I misunderstand the readme/documentation, but I noticed that using Deeplinks.routeWithNavController without subscribing to the results won't gonna work.

What I mean is that following piece of code didn't worked for me:

Deeplinks.routeWithNavController(this.navController, {
   '/about-us': AboutPage,
   '/products/:productId': ProductPage
});

Where that worked

Deeplinks.routeWithNavController(this.navController, {
   '/about-us': AboutPage,
   '/products/:productId': ProductPage
}).subscribe((match) => {
    console.log('Successfully matched route', match);
    }, (nomatch) => {
    console.error('Got a deeplink that didn\'t match', nomatch);
    });

Again thx for the cool plugin ;)

Unable to reach specific route like myapp://about

there i am unable to go specific page, it open the application main page myapp:// and if i pass myapp://about the it also start first page only. so how can go to specific state using deep link. like myapp://about, myapp://menu etc

Support adding associated domains for ios in config.xml

For example, the cordova-universal-links plugin allows you to add a list of hosts within your config.xml to avoid adding those directly in xcode:

<universal-links>
    <host name="example.com">
        <path url="*mypath*" />
    </host>
</universal-links>

or

<universal-links>
    <host name="example.com" scheme="https" event="ul_myExampleEvent" />
</universal-links>

I'd be happy to help add something similar if you're interested in going this direction!

Custom URL Scheme doesn't work without prefix (host) ?

Hi every one,

I have a problem with custom url schemes (deeplinks are OK). I can't make a defined route work without a "host" before...

Ex. :
mycustomurlscheme://whateveryouwant/myregisteredroute/ OK
mycustomurlscheme://myregisteredroute/ ERROR

Here is my AndroidManifest.xml params :

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="mycustomscheme" />
</intent-filter>

In my plaform's ready :

Deeplinks.route({
    '/myregisteredroute/': 'myroute'
}).subscribe((match) => {
    console.log('A deeplink did match');
}, (nomatch) => {
    console.log('A deeplink didn\'t match');
});

Then, when I call a link like : mycustomurlscheme://whateveryouwant/myregisteredroute/
The plugin see 'whateveryouwant' as a host and bring me 'myregisteredroute' as my path. In this case it works but this is not what I'm looking for.

But when I call a link like : mycustomurlscheme://myregisteredroute/
The plugin see 'myregisteredroute' as a host and bring me '/' as my path.

So the defined path (/myregisteredroute/') is never read if there's no character before.

Am I missing something in the plugin params ? In my point of view, if I'm using a CUSTOM scheme, the host shouldn't be taken into account ?
Am I wrong ?

Push Notification opening on InAppBrowser

I have a problem with deep link. When i send push notification, it's working on Android with deep link. But it's not working on IOS. It's opening on native InAppBrowser. I have been use Onesignal for notification.

Random blank screen in ios9(iphone4)

Hi,

Thanks for this plugin and the blog post. We are experiencing a weird bug: a black screen after routing successfully iff the app has not been started. These problem only shows in iphone4(ios9) but not android devices nor ios10 iphone6. The deeplink is triggered by custom scheme.

In our use case, we must share our links into following pattern: SCHEME://HOST_NAME/share?param1=value&param2=value2 instead of SCHEME://HOST_NAME/share/:param1/:param2 or the others.

So we have to come up a config like this:
Deeplinks.route({
'/share': TelegramDetailPage,
})
.subscribe(
(match) => {
console.log('Successfully routed', match);
if("tid" in match.$args)
this.nav.push(detailPage, match.$args);
else if("cid" in match.$args)
this.nav.push(anotherPage, match.$args);
else
this.nav.push(ProfilePage, match.$args);
},
(nomatch) => {
console.warn('Unmatched Route', nomatch);
});

The Component is loaded, data is fetched and everything seems working except showing the white/black screen randomly. We can even click the link to go to another page. If the app has been already started, everything is fine too. We are so lost because there has no error/debug message. We have tested on android and ios devices. Can you please give us some hints?

Ty.

Installation step error

I tried using the installation step from the readme file but it's missing:

  • the character "=" after URL_SCHEME
  • --variable before DEEPLINK_HOST

Which returns the following errors:
Error: invalid variable format: URL_SCHEME
Error: Variable(s) missing (use: --variable DEEPLINK_HOST=value).

The correct format is:
cordova plugin add ionic-plugin-deeplinks --variable URL_SCHEME=myapp --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=example.com

Opening a link in-app on IOS launches new instance of the app

I'm using a messaging framework in my ionic (2) app for in-app chat which gives the option to send users action buttons wrapped as html links, and I've been using this plugin to allow for these buttons to trigger nav changes in the app. This works as expected on Android (tap the link, deep-link observable gets called, and nav-stack gets updated).

However, on iOS doing the same opens a new instance of the app, with the 'back to ' status-bar button. I've added universal link entitlements to the xCode project, but to no avail. I remember the Custom-URL-scheme plugin being able to achieve this kind of functionality with some custom implementation.

Using [email protected], [email protected], and [email protected].

Path resolves on Android, not on iOS

First of all, awesome plugin! I'm having trouble finding out why my deeplink does work on Android, but doesn't on iOS. I'm passing an argument which I then resolve inside the app. The args are picked up on Android, but aren't on iOS.

My deeplink looks like this: customscheme://app/nameOfView/?param={paramId} .
On Android this will result in opening the app, with the right args passed and a matched route. On iOS however, it reports to me that the route is unmatched (and I can't see any args passed as well). Do you have any idea on how to solve this?

in iOS the unmatched route looks like this:
host: "app"
path: "/nameOfView"
queryString: "params=paramID"
scheme: "customScheme"
url: "customScheme://app/nameOfView/?params=paramID"

Thanks for your help in advance!

Enabling automatic url verification for Android

As specified in the documentation, it would be nice to enable automatic url verification for Android apps.

If I understand correctly, the app would be considered automatically as the default one to open the specified url on devices having Android 6.0 or more.

Question - Universal Link in email

Is there something unique I need to do to have the universal link work from an email? I have the link working when clicking from my website so everything appears to be set up correctly. I am using Send Grid on my server to send emails and I have turned click tracking off. When I click the link in my email I get "Safari cannot open the page because the address is invalid".

Use Deeplink in browser

Is it possible to use Deeplinks in the browser (in an ionic v2 app, throught ionic serve)?

When I try, the console outputs the following error:

Native: tried calling Deeplinks.routeWithNavController, but Cordova is not available

Ionic info:

Your system information:

Cordova CLI: 6.1.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Version: 2.0.0-beta.10
Ionic CLI Version: 2.0.0-beta.23
Ionic App Lib Version: 2.0.0-beta.13
OS: Distributor ID: LinuxMint Description: Linux Mint 17.3 Rosa
Node Version: v5.7.0

Ionic 2: possible to use in the browser environment?

I'm trying to use DeepLinks in an Ionic 2 app, in the browser (running via ionic serve) but cordova seems to be required:

plugin.js:33 Native: tried calling Deeplinks.route, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator

Importing from ionic-native
import { Deeplinks } from 'ionic-native';

Is it possible to run in the browser, or only in a device/emulator?

Doesn't save properly in package.json

When the plugin is installed (cordova plugin add... --save) it is saved to the package.json, but with none of the variables, so if you delete the platforms folder and try to build it again, it ends with the error "Failed to install 'ionic-plugin-deeplinks':Error: Variable(s) missing: URL_SCHEME, DEEPLINK_SCHEME, DEEPLINK_HOST".

Is there a way to save all the variables as well?

I tried using this syntax, but no go:

{
      "variables": {
        "URL_SCHEME": "*****",
        "DEEPLINK_SCHEME": "https",
        "DEEPLINK_HOST": "*****.se"
      },
      "locator": "ionic-plugin-deeplinks",
      "id": "ionic-plugin-deeplinks"
}

Plugin does not work with SPA Paths

Trying to switch over to using this plugin over cordova-universal-links-plugin since it's more backwards compatible, but I can't get the plugin to work when my apple-site-association file contains a single-page-application path: /public/#/ResetPassword/*. If I change the path to a wildcard *, then I'm able to tap a link in iOS and have it open in app.

The SPA path works with cordova-universal-links-plugin, albiet with a slight caveat

Check if not deep link

  • Detail: The plugin doesn't tell when a deeplink doesn't happen/when the app start normally.

This is needed when having complex user login structure as well as managing certain UI permission.

phonegap cloud build - support

How to declare these parameters in phonegap build config.xml file
URL_SCHEME=myapp
DEEPLINK_SCHEME=https
DEEPLINK_HOST=example.com

Tried like below
<plugin name="ionic-plugin-deeplinks" source="npm"> <param name="URL_SCHEME" value="myapp" /> <param name="DEEPLINK_SCHEME" value="http" /> <param name="DEEPLINK_HOST" value="mysite.com" /> </plugin>

But getting parameters missing error.

URL_SCHEME not update plist on "ionic build ios" only on "ionic platform add ios"

Hi,

First thx for the awesome plugin, works like charm as always!

Not sure that following is a bug but I thought I should report it, you know just in case...

I noticed that, if you change afterwards respectively after the first installation the URL_SCHEME in the config.xml, that change not gonna be applied to the .plist file of the iOS platform if you only build your application (ionic build ios). To apply such a change, you would have to do it manually in your plist file too or to remove and add the platform again (ionic platform rm ios / ionic platform add ios).

As I said, maybe not a bug, but I lost hours trying to open the app with the wrong url :(
If no bug, I probably miss that in the documentation, as I often always do ;)

How deeplink is handled for on resume event

The issue was discussed on #20

Observation:

  1. When an app starts ondevice ready event fires, then user kills the app.
    if user clicks on a apps link , the plugin opens the app properly and goes to the respective page.(Here onDevice ready will trigger and the deeplink observable serves the incomming deeplink).
  2. Afte step 1 When the app is switched , on pause triggers , now user clicks on an app link from gmail , here plugin opens the app , and the "onResume" event is called .
    Question: Will the same ondeviceready .subscribe() will serve the same scenario ?? In my case it doesn't happen . And it never works on all subsequent pause/resume(flip app and comeback to app again).

To handle this I have added the same call on onResume block :

            $cordovaDeeplinks.route({
                '#/home/xyz': {
                    target: 'xyz',
                    parent: 'home'
                }
            }).subscribe(
                function(match) {
                }, function (nomatch) {       //Since my url doesn't match, i am handling the navigation on nomatch.                        
                    var loc = nomatch.$link.fragment;
                    $rootScope.$apply(function() {
                        $location.path(loc);
                    });
                }
            );

So to summarize i have deeplink route logic both in ondeviceready and onresume call.

And it worked for all the scenario , except :
The on the first onresume call , if the ondeviceready deeplink is consumed already.
1) an app starts, ondevice ready event fires, then user kills the app.
2) user clicked a link from Gmail and app opened.
3) Now switch the app and click the link again - failed----(this is the only case where it fails)
4) Repeat the step-3 -passed - Worked fine
5) Repeat the step-3 - passed - Worked fine

Debugging further , following is finding :
On device ready : The observer on my app , is called before the deeplink object is created on plugin
On Resume : The observer on my app is called after the deeplink object is created on plugin .

To fix this , now i have changed my ondevice ready code as below and removed the deeplink code from onresume.

       //outside onready
      function subscribe_deeplink(){
           $cordovaDeeplinks.route({
                '#/home/xyz': {
                    target: 'xyz',
                    parent: 'home'
                }
            }).subscribe(
                function(match) {
                }, function (nomatch) {
                    $rootScope.isNavigated = true;
                    var loc = nomatch.$link.fragment;
                    subscribe_deeplink();
                    $rootScope.$apply(function() {
                        $location.path(loc);
                    });
                }
            );
        }

       //inside onready
         $cordovaDeeplinks.route({
                '#/home/xyz': {
                    target: 'xyz',
                    parent: 'home'
                }
            }).subscribe(
                function(match) {
                }, function (nomatch) {
                    $rootScope.isNavigated = true;
                    var loc = nomatch.$link.fragment;
                    subscribe_deeplink();
                    $rootScope.$apply(function() {
                        $location.path(loc);
                    });
                }
            );

Now the deeplink works for my app on all the scenarios..

I want to know few things:

  1. Is it a suggested way to go on above way ????
  2. Why onresume scenarios are not discussed on deeplink plugin. How you handle on resume scenarios. Am i missing something on the impplementation

deeplinking to URL not working properly when app is in foreground (inactive state)

I am using ionic-plugin-deeplinks for deeplinking, deeplink works properly when app is in background . But it fails to route when the app is foreground and inactive. My code structure is same as example shared on the plugin.

$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({

}).subscribe(function(match) {

}, function(nomatch) {

** i am using $location.path(loc) for the navigation . As i have few dynamic params on the url .

When app is in background , deeplinking works absolutey fine. Whereas when the app is inactive but running on forground( when user has switched to some other app), clicking on any url open the app but doesn't route to the particular page.

  1. Can i add an event , like universal-links plugin does and listen to the event for routing .

Deeplinks.routeWithNavController Cause exception with ionic serve

Hi

When running ionic serve --lab
the function Deeplinks.routeWithNavController causes:

browser_adapter.js:77 Error: Uncaught (in promise): TypeError: Cannot convert undefined or null to object
    at resolvePromise (zone.js:538)
    at zone.js:574
    at ZoneDelegate.invokeTask (zone.js:356)
    at Object.onInvokeTask (ng_zone_impl.js:37)
    at ZoneDelegate.invokeTask (zone.js:355)
    at Zone.runTask (zone.js:256)
    at drainMicroTaskQueue (zone.js:474)
    at XMLHttpRequest.ZoneTask.invoke (zone.js:426)

any ideas?

ionic info:

Cordova CLI: 6.0.0
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.10
Ionic CLI Version: 2.0.0-beta.32
Ionic App Lib Version: 2.0.0-beta.18
OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.4 LTS
Node Version: v5.9.0

Deeplinks.routeWithNavController breaks my navigation logic.

I'm developing an app using Ionic 2.

The router pushes an page into my navcontroller. It creates an navigation history and an back arrow button in my navbar. But I wish my navigation is made just setting rootPage.

How could I control the navigation so that it sets the rootPage instead pushes another page?

Version 1.0.10

I am using the plugin in PhoneGap Build and the latest NPM version (1.0.9) crashes the build. The log files indicate 3 errors in the lines removed by the latest commit (394f3f4). Can you bump the version up by one in NPM also, so that package uses the codebase with the latest commit? This way we should be able to use the plugin in PhoneGap Build. Currently we are using 1.0.4, as that is the version before the issues were introduced. Thanks!

Deep link fails to launch app and link: iOS 9/10 WKWebView + Ionic 1.5

Deep links with this plugin are working great if the target app is already open. If the app is closed (no task in the OS), and the deep link is fired, iOS opens the app to a blank webview, which loads no html, css, js. Safari remote inspector shows the below error:

screen shot 2016-10-10 at 11 00 56 am

Furthermore, from the remote inspect console, the window.location.href says "about:blank"

The plugin doesn't seem to be gracefully handling the cold launch scenario for a deep link.

Our iOS setup is using WKWebView with the default localhost settings to point to our webview ionic app logic. I feel like this bug is not in our code, and must be something in the native proxy code between the deep link and the ionic client code.

Let me know if I can share any more repro steps or environment attributes to help.

2 Questions regarding the plugin behavior

Hi all

  1. I have notice that the plugin trims the first path of the url why?
    When trying to use the next url to open the app:
    myapp://reset/:token I have notice that the match will be for the :token only
    or another example myapp://reset/pass/:token the match will be for /pass/:token why the first part is being removed?
  2. also I cannot open the app with the DEEPLINK_HOST When im going to my phone browser and type in https://myapp.com/reset nothing happens.. do I miss something?

Your app is using the Advertising Identifier (IDFA)

Hi! And thanks for this great plugin, first of all! :)

I'm in the process of submitting an app to Apple for review, using the latest version of ionic-plugin-deeplinks. When asked about use of IDFA, I checked 'no' but when submitting I get the below message. Searching through my project, the line added in 394f3f4 is the only reference to ASIdentifierManager in my code, and I seem unable to submit the app because of this. Any ideas on how to get around this properly?

Your app is using the Advertising Identifier (IDFA). You must either provide details about the IDFA usage or remove it from the app and submit your binary again.

Looking into the plugin, I can't see what the ASIdentifierManager class is even being used for. Does it play a key role in the deeplinking or can it be removed seeing how sensitive Apple seems to be about using it?

(Repost from comment on #25 )

Error: Cannot read property 'forEach' of undefined

Recently started getting this error. Likely due to a Node upgrade.
I'm running node v6.6.0 and npm 3.10.6

Running command: "/Users/Tyler/Desktop/Web/Tiny Bank/tiny-bank-ionic/hooks/after_prepare/010_add_platform_class.js" "/Users/Tyler/Desktop/Web/Tiny Bank/tiny-bank-ionic"
add to body class: platform-ios
Error: Cannot read property 'forEach' of undefined

Support android:pathPrefix

Correct me if I'm wrong, but if I only want certain links to open in-app for Android, I need to specify the android:pathPrefix attribute in AndroidManifest.xml:

<data android:host="foobar.com" android:scheme="https" android:pathPrefix="/public" />

Would it be feasible to add support for defining the pathPrefix in the config.xml template? I think so but I'm probably not taking everything into account.

iTunes rejection due to excessive using of ASIdentifierManager

Hello!

I'm trying to submit my app to the AppStore and got rejection with the following reason:

We found that your app uses the Advertising Identifier but does not include ad functionality. This does not comply with the terms of the Apple Developer Program License Agreement, as required by the App Store Review Guidelines.

I'm not using any ads in my app and Apple support wants me to remove any usage of:

If your app does not serve ads, please check your code - including any third-party libraries - to remove any instances of:

class: ASIdentifierManager
selector: advertisingIdentifier
framework: AdSupport.framework

There is option to deep link with parent pages?

There is a way, built-in in the plugin that can navigate to deep link with parent pages?

Let's say that is my deep link url: example.com/product/cool-beans

I want that to happened:

this.rootPage = HomePage;
this.navCtrl.push(ProductsPage);
this.navCtrl.push(ProductPage, { name: 'cool-beans' });

It means go to product page with 2 parent pages...

Sorry for bad english.

Generate X-Code Project Entitlements File

Feature Request

One thing that cordova-universal-links-plugin would do is generate the Entitlements file for X-Code. Automating this step removes a manual step that would otherwise be required for deploying to iOS.

Browsing through cordova-universal-links-plugin, it looks like this is the point in their code which generates the entitlement file

It's been quite some time since I've used any cloud-compiler service for cordova projects, but automating this step may be necessary to enable the feature for some projects. You guys probably have a better idea of that though.

Routing with parameters

Hi,

I just replaced cordova-plugin-customurl with this plugin as I believe has much better integration with ionic2.
I cannot find an example or figure out how you handle url params.
For instance if I have a route /activate/12345 works great if I do

{ 'activate/:token': ActivationPage }

and on ActivationPage I do

this._navParams.get('token');

But if I have a route like /activate?token=12345 how can this work?
From the code I understand a route declaration like /activate will not match a link like /activate?token since you are not removing the params before matching the route. Also a declaration of /activate?token will not match either. Am I missing sth?

in Ionic 2 for cold start of app is linking to the Page set in the Home.ts

Hi,

I would like to push the page into the navcontroller, if the app cold started... its working fine in the app is running in the background. if you delete the app and download the new one and click the link its not pushing to the NavController. Its happening in the Ionic2 environment. Please advice

Native: tried calling Deeplinks.route, but the Deeplinks plugin is not installed.

I don`t know why I had this problem. This problem occurred in plugin Cordova network information too, bug when I update the ionic.native fixed.

[Warning] Native: tried calling Deeplinks.route, but the Deeplinks plugin is not installed. (ionic.native.js, line 12411)
[Warning] Install the Deeplinks plugin: 'ionic plugin add ionic-plugin-deeplinks' (ionic.native.js, line 12416)

I am using Ionic 1.7.16

This happen only in iOS, Android work normally

SPA links (using #) do not parse arguments in Android

I have a link like http://www.example.com/#/activate?token=1234&id=55.
The plugin triggers a deep link fine and matches a route definition like /#/activate but the args object is empty.
Java considers everything after # as the fragment part of the Uri and not part of the query string. In the matched object, queryString is undefined and fragment is "/activate?token=1234&id=55"

Opening the same exact url without the has and its following slash works fine btw.

AndroidManifest.xml not updating $DEEPLINK_HOST value

Plugin Version: 1.0.8
Cordova CLI: 6.2.0
Android Platform Version: 5.2.0

Noticed an inconsistency in with how $DEEPLINK_HOST is set in AndroidManifest.xml. When building from scratch (no previous build exists in platforms/android), the value is properly set, but when a previous build exists, the value isn't updated, but other values in the manifest are being updated (android:versionCode, android:versionName, etc.).

Perhaps it's a missing hook?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.