Deep link to another app then callback to the same browser - javascript

I have established deep link connection to the android app from mobile web browser now I want to redirect back specific URL to the same browser that the deep link came from. Currently the callback redirects always to the default browser.
Let's say I can identify the browser using the
navigator.userAgentand pass it as parameter in deep ling to the app. What should be included in URI prefix for the Chrome, Firefox, Safari? To always open callback link in the same browser instead of device default one?
Also is it possible to open the same session instead of always the new tab?

Related

Open redirect link in the same tab using Chrome for iOS

So I have a site that uses a native app to authenticate a user. This is how it works.
I get a token and start polling the app service to check when the user has authenticated.
I use a URI appname:// to open the app for the user, and I provide a redirect link to the app, so that once the authentication is done the user is redirected back to the site.
This works perfectly fine on iOS safari, and using an anchor tag, solved the issue of opening the site in a new tab.
The problems I am facing now is when the user is using the site from Chrome for iOS.
The first problem was that the redirect link was opening in Safari instead of Chrome, however I fixed this by adding googlechrome:// before the redirect url, so having something like this googlechrome://mysite.com#anchor
However I still have the issue that googlechrome://mysite.com#anchor always opens in a new tab, which obviously reloads the site, thus the polling would not have been started, but if I manually go back to the previous tab, the polling is still ongoing and the user is logged in.
My question is: Is there a way to use this kind of URI redirect for Chrome for iOS to open in the same tab?
I found the solution to this.
So basically if you just put googlechrome:// without specifying a url after it, this will open chrome for iOS in the current tab.

JavaScript - one link, all app stores, non-Safari detected

I'd like to have a single 'Get App' link that auto-detects the user's device type and browser and directs to the appropriate location (iTunes, Google Play, or website sign-up). I am currently using Onelink.to, but it has the following limitations:
if you're on iOS using a non-Safari browser (like Chrome) you end up looking at a bunch of raw JSON because it doesn't know to launch the App Store app. In this case, I'd prefer to direct to the iTunes website or better yet, deep link into the App Store app.
if using the link on your own site and a user is on a device that redirects to a different page of your own website, it complicates setting up event-based goals in Google Analytics
Are there any good JavaScript solutions that handle the App Store redirect while excluding this action on browsers that don't support the iTunes headers?
Thanks!
You can use javascript navigator.userAgent and parse it to detect the device. Then just generate the link according to it.
Here is an example for ios detection:
Detect if device is iOS

Possible to open link in Chrome Application from javascript?

From the command line, I can open a url as a chrome application by running e.g.
chromium --app=https://www.stackoverflow.com
Is it possible to do open a url in this mode from javascript in an existing page? To be clear, the url should ideally be opened in a new window, which has the properties implied by the --app flag (e.g. no address bar), whether or not the current page is running in that mode.
My reason for asking is that I'd like to integrate this into vimium.
There is no way to do what you need directly from Javascript. I think you'll need to create an Chrome extension to do that.
You still can find an extension called "Open with external application" which do that, but its use NPAPI and NPAPI is not supported anymore by latest Chrome version. The source is hosted on BitBucket.
The new way to do the same thing is using the native messaging API. In this case the external application would have to register a native messaging host in order to exchange messages with your application. You can see more at http://developer.chrome.com/extensions/messaging.html#native-messaging

Open non-whitelisted URLs in Cordova in ChildBrowser rather than main Webview

I'm trying to implement the official Twitter and Facebook share buttons in my Cordova/Phonegap app, and I'm running into major difficulties with them. Both of them attempt to load an iframe element to display their buttons, which works, but clicking either of them causes them to open in the Webview, with no way to open them instead in the ChildBrowser. This becomes an issue when the user is done sharing but can't go back to the app due to a lack of navigation buttons.
Is there some way to open a list of URLs in ChildBrowser by default instead of Webview?
Well you can use the:
ChildBrowser.showWebPage();
command to open non-white listed URL's.
Coming in 2.3.0 we will overload window.open() in so that you can specify whether or not you want the url opened in the main web view, the OS browser or the special in app browser that does not have access to the Cordova API.

Closing a mobile browser tab with javascript

I need a native app to fire a browser with some URL that will take the user to a mobile website. Inside the mobile website, there has to be a button that closes the browser (or sends any signal to the native app) so that the user gets back to the native app. Currently I'm trying to close the window, but I don't think that's gonna do the trick in all mobile devices.
My code:
$( document ).bind('pageinit', function(){
$.mobile.activePage.find('#close').click(function(){
window.open('', '_self', '');
window.close();
});
});
I'm using jQuery mobile.
Setup a custom URI handler (for Android and for iOS). Then all you have to do is redirect to a URL that matches, perhaps using window.location.
It seems that there are security restrictions that wouldn't allow you to close the window via JavaScript. See here
EDIT: You basically have two options: implement a custom URL handler for each platform you're developing for; or embedding a web view into your application (UIWebView for iOS or WebView for Android).
On iOS if you launch Safari from your app you won't be able to get back to your app after Safari closes, unless your app is registered as a custom URL handler and the page you are on launches a URL that launches your app.
On iOS if instead of launching Safari you show the web page in a UIWebView you have control over exiting the page.

Categories