I'm building an AngularJS (1.x) and Ionic/Cordova mobile app for iOS + Android. I'd like to add/create a "deep link" to my Sign In page so that when I send a new user a "Confirm your Email" email and they click a link to confirm their registration, then if they're on their mobile device (with my app installed) they'll be taken into the app directly to the Sign In page.
I see this plugin but I have no experience creating deep links in AngularJS/Ionic/Cordova apps. Any ideas?
If you are unsure about deep linking, it will increase the robotic impressions of your page which will increase the number of crawlers.
If you want to learn more about deep linking visit the following link: http://www.divami.com/blog/deep-linking-angular/
Now, the thing you want to implement is authentication of the existing users making and API call to the server that will check to see if the user already exists. If the user exists they will be taken to the login page else they will be taken to the registration page. This can be achieved using resolvers in angularjs.
Below is a link on how to implement this:
https://medium.com/opinionated-angularjs/advanced-routing-and-resolves-a2fcbf874a1c
Since you are using cordova use this plugin, it will help you started for IOS and Android easily.
Install plugin with URL Scheme with below cmd
$ cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=mycoolapp
That's it, now your app can referenced with
Open my app
You can send authentication code along with your URL like
Open my app
To retrieve code in your App
function handleOpenURL(url) {
console.log("received url: " + url); ==> this will returnURL after://
}
From this you can authenticate the user in your app itself. This is simple way as you are new to deeplinking. Go through the rules in plugin to know more about the naming convention for custom URL(mycoolapp)
Try this plugin it works great.
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();
As you can see, now you subscribe to an event via universalLinks module when the ready device is fired.
Actually, you can subscribe to it in any place of your application: plugin stores the event internally and dispatches it when there is a subscriber to it.
here is a link the tells how to deep link
https://blog.ionicframework.com/deeplinking-in-ionic-apps/
Install the 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 app's module
the below links explains more about that
https://ionicframework.com/docs/native/deeplinks/
Related
Currently I am working on a Project which is implemented in Ionic 1 and AngularJs.
Now we are working to integrate it with BHIM UPI to perform In-App payment. I think we need to install IONIC Native Web Intent plugin in order to make web intent call to BHIM.
But I am fairly new to angularJs and Ionic. I have seen some of the questions related to this but those are implemented in Ionic3 and latest versions.
UPI Deeplinking from IONIC to GooglePay does not work as expected
DEEPLINK_HOST in ionic deeplink
Deeplinking - Opening an Ionic App through another Ionic App
I have tried to achieve this by making Web Intent calls with help of this https://www.npmjs.com/package/#ionic-native/web-intent?activeTab=readme but with no luck. It's giving Error message like below
ionic.bundle.min.js:150 Error: [$injector:unpr] http://errors.angularjs.org/1.5.3/$injector/unpr?p0=webIntentProvider%20%3C-%20webIntent%20%3C-%20PaymentComponent%20%3C-%20PaymentComponent
at http://localhost:8100/js/ionic.bundle.min.js:40:416
at http://localhost:8100/js/ionic.bundle.min.js:77:7
at Object.d [as get] (http://localhost:8100/js/ionic.bundle.min.js:74:270)
EDIT :
I want to open BHIM UPI app from my Ionic App and able return success or failure status of transaction.
Any help or directions to achieve this will be highly appreciated.
There is no 'webIntentProvider' exists in ionic providers.
You've to remove 'webIntent' from your controllers injections. And use below code to open existing UPIs available in your mobile.
window.plugins.intentShim.startActivity(
{
action: window.plugins.intentShim.ACTION_VIEW,
url: urlIntent
},
function () { },
function () {
alert('Failed to open URL via Android Intent')
}
);
It'll show all available UPI providers which are installed in your mobile. Please go through documentation Deeplinking UPI for more details.
Cross check your package.json & confilg.xml, whether you installed above plugin in your app or not.
I'm working on an Ionic app that uses Twitter login through an OAuth pop up and redirects from the login page to the main dashboard. It works fine on Desktop, but when compiled as an ionic app (Android in this case) the login window opens, redirects back to the app, but then nothing happens - neither of the two functions (redirect to the dashboard page, and create a new user) fire.
I've read pretty much every similar question and tutorial on this and just can't find the issue. I've got the Cordova in app browser installed to handle the popup, and I've tried callback functions, $timeouts, $onAuth watching - all work perfectly on a browser, and in the in-browser emulator ionic provides, but not at all when compiled to an app on the phone.
Any help is massively appreciated.
My current code in my controller:
$scope.login = function() {
Auth.auth.$authWithOAuthRedirect('twitter').then(function(authData) {
// User successfully logged in
}).catch(function(error) {
if (error.code === "TRANSPORT_UNAVAILABLE") {
Auth.auth.$authWithOAuthPopup('twitter').then(function(authData) {
// User successfully logged in. We can log to the console
// since we’re using a popup here
console.log(authData);
});
} else {
// Another error occurred
console.log(error);
}
});
};
// Update profile and forward to homepage
Auth.auth.$onAuth(function(authData) {
console.log('Logged in as', authData.uid);
console.log(authData);
// Update/Create profile
Auth.new(authData);
// Forward to homepage
$state.go('tab.dash');
});
As #mhartington points out the whitelist plugin needs to be installed and the following two lines added to the config.xml as per this tutorial
<allow-intent href="*.firebaseio.com" />
<allow-intent href="auth.firebase.com" />
Hope this helps anyone else banging their heads against a brick wall with this!
Looks like you just needed to add the whitelist plugin and allow access to the firebase urls
I am using Ionic and Oauth.io to perform authentication. If I run ionic serve and include the outh.js file in my index everything works good from the browser.
But when I run ionic run ios or install the app in android, I get the following error when I press the auth button (the one that suppose to execute OAuth.popup
I do not know what to do, until now I have checked the following:
In config.xml I have access, allow-intent and allow-navigation full permisive
I have installed and re-installed the plugin ionic plugin add https://github.com/oauth-io/oauth-phonegap.git
I tried to run the native app without the inclusion of the oauth.js file and everything breaks.
Using current versions up to date.
I am new to Ionic, so I don't know how to debug the device-running app or simulator.
Could be similar to this post but not exactly .
Your advices will be appreciated.
I figure it out reading some posts. The OAuth initialization and references should be done after the device is ready, so it is best to put the initialize in this block:
$ionicPlatform.ready(function() {
// ...
if(typeof window.OAuth !== 'undefined'){
$rootScope.OAuth = window.OAuth;
$rootScope.OAuth.initialize('XXX');
}
else{
console.log("plugin not loaded, this is running in a browser");
$.getScript( "lib/oauth.js", function() {
$rootScope.OAuth = OAuth;
$rootScope.OAuth.initialize('XXX');
});
}
});
Now, if the plugin is loaded it initializes the window.OAuth object, else the app is running in browser, so I have to include the oauth.js file. Also I assigned the OAuth to the $rootScope for quick access.
Hope this helps anyone.
Using Cordova PushPlugin and AngularJS I want to receive a push notification and read a URL in the payload and then navigate to that page when the notification is swiped open.
How is this accomplished?
I tried this, but this is inside of a global function that is outside of angular so I wouldn't suspect the $location to work. It doesn't throw any errors though, but it also does not navigate to the url from the payload.
function onNotificationAPN(event) {
$location.path(event.custom.url)
});
You can try this: Create a service "PushService" and invoke the service like below
function onNotification(event) {
var injector = angular.element(document.body).injector();
injector.invoke(function (PushService) {
PushService.onNotification(event);
});
}
I created a tool to generate app with push notification integration with cordova and ionic. You can check it out Ionic app builder
currently, I run backbone as the front-end of my rails 3.2 application. I need to migrate it into an independent JS application, as part of my putting it as part of Trigger.io.
It now exists as its own index.html file, referencing the assets folder.
When I open the file, it loads the Backbone modules, but the page remains empty. And when I run fetch() commands, it
So, I got a couple of qns:
1) How do I trigger the routes such that it goes to a designated page by default?
I know it gets triggered in Backbone.History.Start, but I am not sure what to do before that.
2) The url is "file://localhost/Users/mingyeow/Desktop/index.html"
How do I set the root url manually to use localhost:3000/my web address?
// define router
var Router = Backbone.Router.extend({
routes : {
'index' : 'indexAction',
'*default' : '_defaultAction'
},
indexAction : function() {
// this will be executed when user navigate to #index
},
_defaultAction : function() {
// this will be executed when user navigate anywhere else (#XXX)
}
});
// on document ready
$(function() {
// initialize router
new Router();
// and start history
Backbone.history.start();
});
You can navigate this way.
Or by clicking the link : Index route
You can use python server. To start it type in the Terminal:
$ python -m SimpleHTTPServer
And check http://localhost:8000
1) To trigger a route change you just need to navigate to a page via a href or JavaScript like window.location. Read up on Backbone Routes but essentially you need to write a function for every 'page'. Each function should take care of rendering the page.
2) This should be very simple. You need a local web server. What I started doing recently is just having a simple Node server. Node is very easy to install and its worth experimenting with. Download a static web server such as this one I made. To use it just put your backbone application in a directory named 'public' and run server.js in node.
If you don't want to do this you can run a simple LAMP/WAMP/MAMP installation and set the root of the Apache web server.