• This repository has been archived on 17/Aug/2023
  • Stars
    star
    332
  • Rank 126,957 (Top 3 %)
  • Language
    Objective-C
  • License
    Other
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

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)

Set up Android App Links

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.

More Repositories

1

ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
TypeScript
49,820
star
2

ionicons

Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎
TypeScript
17,166
star
3

stencil

A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
TypeScript
11,913
star
4

capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
TypeScript
11,539
star
5

ionic-conference-app

A conference app built with Ionic to demonstrate Ionic
TypeScript
3,543
star
6

ng-cordova

OBSOLETE: Please move to Ionic Native https://github.com/ionic-team/ionic-native
JavaScript
3,499
star
7

ionic-cli

The Ionic command-line interface
TypeScript
1,991
star
8

ionic-angular-cordova-seed

The perfect starting point for an Ionic project
JavaScript
726
star
9

ionic-pwa-toolkit

Build lightning fast Progressive Web Apps with zero config and best practices built-in. Go from zero to production ready with Ionic and Stencil (Web Components).
TypeScript
634
star
10

ionic-plugin-keyboard

Ionic Keyboard Plugin for Cordova
C++
613
star
11

ionic-app-scripts

App Build Scripts for Ionic Projects
TypeScript
612
star
12

ionic-docs

HTML
581
star
13

ionic-react-conference-app

The Ionic Conference Demo App - Now in React
TypeScript
498
star
14

capacitor-plugins

Official plugins for Capacitor ⚡️
Java
491
star
15

cordova-plugin-ionic-webview

Web View plugin for Cordova, specialized for Ionic apps.
Objective-C
482
star
16

ionic-site

Repo for the ionicframework.com site
JavaScript
453
star
17

capacitor-assets

Local Capacitor icon/splash screen resource generation tool
TypeScript
448
star
18

starters

Starter templates for Ionic apps, used by the Ionic CLI
JavaScript
446
star
19

ionic-app-base

A base starting point for Ionic, with Cordova, Bower, and Gulp.
JavaScript
424
star
20

ionic-ion-tinder-cards

Add Tinder-style card swiping to any app with this simple Ionic Ion.
JavaScript
390
star
21

ionic-storage

Ionic Storage module for Ionic apps
TypeScript
389
star
22

ionic-starter-super

The Ionic 2 Super Starter 🎮
TypeScript
382
star
23

ionic-unit-testing-example

Example of adding unit testing in your Ionic 2.x or greater apps with Karma and Jasmine
TypeScript
378
star
24

ionic-ion-swipe-cards

Swipeable card based layout for Ionic and Angular
JavaScript
354
star
25

stencil-site

Stencil site and documentation source.
TypeScript
318
star
26

graphite

Clean jQuery Mobile theme-pack and theme generator
JavaScript
302
star
27

stencil-component-starter

Minimal starter project for building shareable web components with Stencil https://github.com/ionic-team/stencil
TypeScript
263
star
28

stencil-ds-output-targets

These are output targets that can be added to Stencil for React and Angular.
TypeScript
247
star
29

ionic2-starter-aws

Ionic + AWS MobileHub Starter Project
JavaScript
238
star
30

collide

A powerful javascript animation engine for web and hybrid mobile apps, inspired by Facebook Pop, built by the Ionic team.
JavaScript
234
star
31

ionic-native-google-maps

Google maps plugin for Ionic Native
TypeScript
223
star
32

ionic2-app-base

Template for starting Ionic 2 apps, used by the Ionic CLI
CSS
222
star
33

front-page

An example Hacker News app showcasing what's possible with Ionic
JavaScript
198
star
34

trapeze

The mobile project configuration toolbox. Manage native iOS, Android, Ionic/Capacitor, React Native, and Flutter apps through a simple YAML format.
TypeScript
194
star
35

ionic-v1

The repo for Ionic 1.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
JavaScript
192
star
36

ionic-starter-tabs

A starting project for Ionic using a simple tabbed interface
HTML
161
star
37

ionic-ion-header-shrink

A demo of making a header that shrinks based on the user scrolling (like Facebook's iOS app).
JavaScript
161
star
38

creator-weekly-workshops

Here you can find any code that we use in the Creator Demo Videos
JavaScript
154
star
39

ionifits

Human Resources demo app (Zenefits clone) serving as a reference for enterprise app developers on the Ionic stack.
TypeScript
152
star
40

ionic-example-cordova-camera

An example of how to use the Cordova Camera API
JavaScript
150
star
41

stencil-store

Store is a lightweight shared state library by the StencilJS core team. Implements a simple key/value map that efficiently re-renders components when necessary.
TypeScript
149
star
42

ionic-starter-maps

An Ionic starter project using Google Maps and a side menu
JavaScript
143
star
43

tutorial-photo-gallery-angular

Photo Gallery Tutorial: Ionic Angular and Capacitor
TypeScript
139
star
44

pwa-elements

Quality UI experiences for Web APIs that require custom UI (such as media/camera).
TypeScript
135
star
45

ionic-v3

The repo for Ionic 3.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
TypeScript
129
star
46

ionic-starter-sidemenu

A starting project for Ionic using a side menu with navigation in the content area
JavaScript
126
star
47

native-run

Utility for running native binaries on iOS and Android devices and simulators/emulators
TypeScript
123
star
48

ionic-contrib-frosted-glass

An optional frosted-glass effect for iOS 7 styled Ionic apps.
JavaScript
123
star
49

ionic-heroku-button

A one-click Ionic app template for Heroku
JavaScript
123
star
50

ionic-starter-cardboard

A google cardboard template for Ionic
JavaScript
113
star
51

ionic-pwa-demos

A collection of cool Ionic Progressive Web App demos. PR to add your own!
JavaScript
109
star
52

rollup-plugin-node-polyfills

JavaScript
108
star
53

ionic-vue-conference-app

Ionic Conference app ported to Vue
Vue
104
star
54

ionic-stencil-hn-app

Ionic Stencil HackerNews App
TypeScript
103
star
55

ionic-module-template

A template for building a reusable Angular 2 module for Ionic 2 apps
TypeScript
96
star
56

stencil-state-tunnel

A tool for tunneling state/props down through a component stack.
TypeScript
95
star
57

stencil-redux

TypeScript
95
star
58

ionic-bower

Bower repository for Ionic
JavaScript
93
star
59

ionic-stencil-conference-app

A conference app built with Stencil to demonstrate Ionic
TypeScript
90
star
60

ionic-present

Present Ionic in your town. Share the new way to build mobile apps.
JavaScript
90
star
61

capacitor-remix-templates

Build native iOS, Android, and Web apps with Capacitor and Remix.run 💿
Swift
90
star
62

ionic2-starter-tutorial

This tutorial goes along with the example on Ionic v2 documentation
TypeScript
87
star
63

ionic-starter-salesforce

A starter project for Ionic and Salesforce
JavaScript
85
star
64

cordova-plugin-ionic

Ionic Cordova SDK
TypeScript
78
star
65

ionic-proxy-example

A quick Ionic project showing how to use the proxy server
JavaScript
75
star
66

docs-demo

A demo/kitchen sink for the docs
TypeScript
74
star
67

ionic-contrib-firebase-login

Using Firebase's angularFire and simple login with Ionic
JavaScript
69
star
68

ionic-package-hooks

Cordova hooks that you can run in Ionic Package
JavaScript
69
star
69

stencil-sass

Sass plugin for Stencil
TypeScript
69
star
70

angular-toolkit

Angular Schematics and Builders for `@ionic/angular` apps.
TypeScript
68
star
71

ionic2-starter

An Ionic2 starter project
68
star
72

tutorial-photo-gallery-react

Photo Gallery Tutorial: Ionic React and Capacitor
TypeScript
68
star
73

legacy-ionic-cloud

JavaScript Client for legacy Ionic Cloud services. See Ionic Pro for our new take on the ionic development lifecycle
TypeScript
65
star
74

photo-gallery-tutorial-ionic4

Ionic framework v4 tutorial: Building a Photo Gallery!
TypeScript
64
star
75

ionic-learn

CSS
62
star
76

ionic-ion-frost

A reusable frosted-glass effect for adding this cool iOS effect to your Ionic apps.
JavaScript
62
star
77

create-capacitor-plugin

Create a new Capacitor plugin ⚡️
Mustache
58
star
78

tutorial-photo-gallery-vue

Photo Gallery Tutorial: Ionic Vue and Capacitor
CSS
57
star
79

ionic2-starter-tabs

A starting project for Ionic using a simple tabbed interface
TypeScript
53
star
80

ionic-portals

Portals Javascript Library and Docs
JavaScript
52
star
81

ionic-ion-drawer

A side menu drawer for Ionic apps
JavaScript
51
star
82

tslint-ionic-rules

Common TypeScript lint rules/preferences for Ionic.
TypeScript
50
star
83

stencil-router-v2

TypeScript
45
star
84

ionic-app-lib

The library used for using ionic apps - consumed by the CLI and the GUI
JavaScript
44
star
85

capacitor-starters

A collection of projects to use as a resource for new Capacitor apps
JavaScript
44
star
86

stencil-ds-plugins-demo

This is a demo project using the stencil-ds-plugins.
TypeScript
44
star
87

create-stencil

npm init stencil
TypeScript
43
star
88

ionic-gulp-tasks

Collection of gulp tasks for building Ionic apps
JavaScript
41
star
89

ionic2-starter-sidemenu

A starting project for Ionic with side menu navigation
TypeScript
41
star
90

ionic-code

Ionic code
JavaScript
40
star
91

stencil-ds-react-template

This is an example repo of building plugins.
TypeScript
37
star
92

appflow-build

GitHub Action for triggering Appflow Builds
TypeScript
36
star
93

stencil-inspector

TypeScript
36
star
94

ionic2-deeplinks-demo

A test repo for deep linking in Ionic 2
JavaScript
35
star
95

capacitor-background-runner

C
35
star
96

ionic-ion-ios-buttons

Simple iOS 7 style rounded buttons with CSS
34
star
97

portals-ecommerce-demo

E-commerce Demo App using Ionic Portals
Java
33
star
98

ionic-e2e-example

Example app for Ionic E2E
TypeScript
32
star
99

capacitor-testapp

TypeScript
32
star
100

eas-2021

Conference app for the Ionic Enterprise App Summit 2021.
TypeScript
31
star