Reinforcement in AngularJS / Ionic as an example

I am creating an AngularJS (1.x) and Ionic / Cordova mobile app for iOS + Android. I would like to add / create a "deep link" to my Login page , so that when you send a new user, "Confirm Email" and click the link to confirm their registration, then if they are on your mobile device (with my application installed) ), they will be sent to the application directly to the login page.

I see this plugin , but I have no experience creating deep links in AngularJS / Ionic / Cordova applications. Any ideas?

+4
source share
4 answers

cordova, , IOS Android.

URL- cmd

$ cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=mycoolapp

,

<a href="mycoolapp://">Open my app</a>

URL-,

<a href="mycoolapp://somepath?OauthCode=789456">Open my app</a> 

function handleOpenURL(url) {
  console.log("received url: " + url); ==> this will returnURL after://
}

. , deeplinking. , URL (mycoolapp)

+2

, .

document.addEventListener('eventName', didLaunchAppFromLink, false);
function didLaunchAppFromLink(event) {
  var urlData = event.detail;
  console.log('Did launch application from the link: ' + urlData.url);
  // do some work
}
var app = {
  // Application Constructor
  initialize: function() {
    this.bindEvents();
  },
  // Bind Event Listeners
  bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
  },
  // deviceready Event Handler
  onDeviceReady: function() {
    universalLinks.subscribe('eventName', app.didLaunchAppFromLink);
  },
  didLaunchAppFromLink: function(eventData) {
    alert('Did launch application from the link: ' + eventData.url);
  }
};
app.initialize();

, UniversalLinks .

In fact, you can subscribe to it anywhere in your application: the plugin stores the event inside itself and sends it when there is a subscriber.

+2
source

here is a link that tells how deep the link is   https://blog.ionicframework.com/deeplinking-in-ionic-apps/

Install Cordova and Ionic Native plugins:

$ ionic cordova plugin add ionic-plugin-deeplinks --variable URL_SCHEME=myapp --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=example.com --variable ANDROID_PATH_PREFIX=/
$ npm install --save @ionic-native/deeplinks

Add this plugin to your application module below links explain more about it

https://ionicframework.com/docs/native/deeplinks/

0
source

Source: https://habr.com/ru/post/1694474/


All Articles