We use gapi.js for Google authorising.
It works correct on majority of desktop browsers and on mobile Safari.
But it doesn't on Mobile Chrome IOS(41.0.2272.58).
In the begging we load gapi.js script
require(['https://apis.google.com/js/client.js?onload=gapiIsLoaded'];
Then we try authorize using:
gapi.auth.authorize(params, handler);
Params are
var params = {
client_id: MY_CLIENT_ID,
scope: MY_SCOPES,
immediate: false // to open popup
};
Browsers shows popup and I can autorize and continue work.
IOS Safari works correct too.
But Chrome IOS never calls handler callback.
This issue extends to Chrome for Android 5.0. In my case, downgrading to 39.0.2171.59 resolves the problem. Hopefully this information puts you closer to finding the root cause.
Issue was resolve by adding redirect ur instead of window open https://github.com/google/google-api-javascript-client/issues/189
I have a webpage, lets call it entry.html.
When a user enters this page, a javascript code (see below) is attempting to deep-link the user to the native iOS / Android app.
If the deep-link fails (probably if the app isn't installed on device), user should "fall back" to another page- lets call it fallback.html.
here is the javascript code that is running on entry.html:
$(function(){
window.location = 'myapp://';
setTimeout(function(){
window.location = 'fallback.html';
}, 500);
});
this is a standard deep-linking method that is recommended all over the network; try to deep-link, and if the timeout fires it means that deep-link didn't occur- so fallback.
this works fine, as long app is installed on device.
but if the app isn't installed, this is the behaviour when trying to deep-link:
Mobile Safari: I see an alert message saying "Safari cannot open this page..." for a moment, and then it falls-back properly to fallback.html- which is the expected behaviour.
Mobile Chrome is my problem.
when the app isn't installed, browser is actually redirected to the myapp:// url, which is of course, invalid- so i get a "not found" page, and fall-back doesn't occur.
Finally- my question is:
How can I fix my code so FALL-BACK WILL OCCUR on mobile Chrome as well? just like mobile Safari?
note: i see that LinkedIn mobile website does this properly, with Safari & Chrome, with or without the app installed, but i couldn't trace the code responsible for it :(
note2: i tried appending an iframe instead of window.location = url, this works only on Safari, mobile Chrome doesn't deep-link when appending an iFrame even if app is installed.
Thanks all!
UPDATE:
i found a decent solution, and answered my own question. see accepted answer for my solution.
for whoever is interested, i managed to find a decent solution to solve these issues with deeplinking Chrome on Android.
i abandoned the myapp:// approach, i left it functioning only in cases of an iOS device.
for Android devices, i'm now using intents which are conceptually different than the myapp:// protocol.
I'm mainly a web developer, not an Android developer, so it took me some time to understand the concept, but it's quite simple. i'll try to explain and demonstrate MY solution here (note that there are other approaches that could be implemented with intents, but this one worked for me perfectly).
here is the relevant part in the Android app manifest, registering the intent rules (note the android:scheme="http" - we'll talk about it shortly):
<receiver android:name=".DeepLinkReceiver">
<intent-filter >
<data android:scheme="http" android:host="www.myapp.com" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
now, after this is declared in the app manifest, i'm sending myself an email with "http://www.myapp.com" in the message.
when link is tapped with the Android device, a "chooser" dialog comes up, asking with which application i want to open the following? [chrome, myapp]
the reason this dialog came up upon tapping on a "regular" url, is because we registered the intent with the http scheme.
with this approach, the deeplink isn't even handled in the webpage, it's handled by the device itself, when tapping a matching link to an existing intent rule defined in the Android app manifest.
and yes, as i said, this approach is different by concept than the iOS approach, which invokes the deeplink from within the webpage, but it solves the problem, and it does the magic.
Note: when app isn't installed, no chooser dialog will come up, you'll just get navigated to the actual web page with the given address (unless you have more than 1 browser, so you'll need to choose one... but lets not be petty).
i really hope that this could help someone who's facing the same thing.. wish i had such an explanation ;-)
cheers.
It is very important to make sure that when you try to open a deeplink URL with JavaScript that the URL is properly formatted for the device and browser. (If you do not use the appropriate deeplink URL for the browser/platform, a user may be redirected to a “Page Not Found”, which is what you experience.)
Now you must note that Chrome on Android has a different URL format than the old standard Android browser 1! You need to annotate the deep links using href="android-app://" in the HTML markup of your web pages. You can do this in the section for each web page by adding a tag and specifying the deep link as an alternate URI.
For example, the following HTML snippet shows how you might specify the corresponding deep link in a web page that has the URL example://gizmos.
<html>
<head>
<link rel="alternate"
href="android-app://com.example.android/example/gizmos" />
...
</head>
<body> ... </body>
For more details, see the references here:
https://developer.chrome.com/multidevice/android/intents
https://developers.google.com/app-indexing/webmasters/server
https://developer.android.com/training/app-indexing/enabling-app-indexing.html#webpages
And here's a deep link testing tool for Android: https://developers.google.com/app-indexing/webmasters/test.html
Hope that helps.
1 Since the old AOSP browser was replaced by chromium, this is now the default way to handle deep links for recent Android versions. Nonetheless, Android still requires a conditional soltion, because older OS versions still use the AOSP browser.
I have created a Javascript plugin, which supports most of the modern browsers on mobile. But it requires to have deep linking landing pages to be hosted on cross domain(different than universal link url) to work on ios9 Facebook using universal linking. There is also different way to get that working on the Facebook iOS9 using Facebook SDK. I am sharing this if anyone might find this helpful. Currently it does not fallback option, but if falls back to the App Store.
https://github.com/prabeengiri/DeepLinkingToNativeApp
I am Using this Code to for deeplinking.
If the app is installed the app will open up..
If the app is not installed then this remains as it is..
If you wish to add any other condition for app no install then just uncomment the setTimeout code .
<script>
var deeplinking_url = scootsy://vendor/1;
$(document).ready(function(){
call_me_new(deeplinking_url);
});
var call_me_new = function(deeplinking_url){
if(deeplinking_url!=''){
var fallbackUrl ='http://scootsy.com/';
var iframe = document.createElement("iframe");
var nativeSchemaUrl = deeplinking_url;
console.log(nativeSchemaUrl);
iframe.id = "app_call_frame";
iframe.style.border = "none";
iframe.style.width = "1px";
iframe.style.height = "1px";
iframe.onload = function () {
document.location = nativeSchemaUrl;
};
iframe.src = nativeSchemaUrl; //iOS app schema url
window.onload = function(){
document.body.appendChild(iframe);
}
//IF the App is not install then it will remain on the same page.If you wish to send the use to other page then uncomment the below code and send a time interval for the redirect.
/*
setTimeout(function(){
console.log('Iframe Removed...');
document.getElementById("app_call_frame").remove();
window.location = fallbackUrl; //fallback url
},5000);*/
}
};
</script>
setTimeout(function () { if (document.hasFocus()) { window.location = 'URL WILL BEHERE';} }, 2000);
window.location = 'app://';
Need to check document.hasFocus() here because if app is open then playstore url is also open in browser
I also had similar issue, there is a possible alternative for this. If the app is not installed on user's device we can redirect that to some other url.To know more about it Check Here
Example:
Take a QR code
In my case its working fine in opera and chrome browser my deeplink url is
"intent://contentUrl + #Intent;scheme=" +envHost +;package="+envHost+";end";
For other browser create iframe and append the url.
Note -: iframe url append having issue with old device and in firefox its opening app dialog .
I have a mobile app using angular.js, Twitter Bootstrap, and grunt with a .NET back end. that after login will constantly show the loading spinner up in the top nav next to the time and battery status. We make server calls at login through a factory using a timeout and promise.
login: function (credentials) {
var that = this;
return login(credentials)
.then(function() {
$timeout(function() {
that.getFamily().then(function (family) {
$cookies.familyId = family.id.toString();
Cart.getCart();
});
}, 100);
});
}
var login = function (credentials) {
return $http.post('/family/login', credentials);
};
We aren't using long polling, so all of the solutions to that problem that I've found won't help. It only happens on mobile safari on ios. Nothing on chrome, firefox, etc. in browser or on mobile devices. I've tried setting a datetime stamp on the POST as well as removing various apple meta tags and nothing helped. I've read around and I've seen all over that there are issues with ios6+ caching posts, which could cause the never ending spinner. I've also just read it's an ios bug, so who knows.
Please help!
I have observed the same problem for fullScreen iOS webApp's installed on the homeScreen. I'm sure it's a bug, but I can remove the spinner with a hard reSet or by reStarting the device. After reSet, the webApp runs without problems until the day the device detects some random netWork problem on loading the app. This problem is remembered by your device until it's reSat.
The bug first occured in iOS 6 but unfortunately not solved on iOS 7.
We are trying to build an parameterized entry webpage for our app in which about 50% of users will have our app installed, 50% not.
Originally, we had been using a specialized URL scheme that our app had registered; ie,
myapp://dothing?specialParameters=5
However, we have difficulty detecting cases where users either don't have our app installed, or have an earlier version of our app that doesn't support URL schemes. In Chrome, or the Android Browser, the user is navigated to a browser-generated Error page since it couldn't locate the server.
In iOS Safari, and Android Firefox, we can resolve this through the use of a setTimeout before navigation;
function timeoutFn() {
var timeout = setTimeout(function() {
window.location = //iOS Appstore location;
}, 1000);
window.addEventListener("pagehide", function(evt) {
clearTimeout(timeout);
});
window.location = "myApp://dothing?specialParameters=5";
}
My solution for Chrome/Android Browser is to use Google's recommended system of Intents, described here:
https://developers.google.com/chrome/mobile/docs/intents
I've tested this out, and it actually seems to work well - however, Firefox does not know how to handle links beginning with "intent://". We can still use the above JavaScript function for Firefox, but I'm very reluctant to start writing user-agent-sniffing code for it, especially since I'd think it likely any other web browsers on Android will similarly lack Intent support.
So, back to the title question: Chrome, and the Android browser, are capable of opening apps through "intent://" links - is there any way, using JavaScript or similar methods, to use feature detection to find this support?
This is what we are currently using, however, it's far from ideal ...
function isItentsSupported() {
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if (isChrome) {
var version = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);
return version >= 25;
} else {
return false;
}
}
Chrome version number based on Google documentation
Callback method is not get called after successful Login to the Google in Safari browser (IOS 6 and lower versions). But it's working perfect for all other Desktop browsers and android devices. It is even working perfect in Safari IOS 7. But I couldn't able to trace out why it's not get called after the successful login process. After Login the popup window gets closed, but nothing is happened in the main window (callback method is not called by the browser).
Here is my code:
var token = gapi.auth.getToken();
if(token)
driveCallBack();
else
this._doAuth(false, function() { driveCallBack(); }.bind(this));
Sample Code: https://gist.github.com/Daniel15/5994054
Here I'm not using the Google Drive File Picker, instead of that I'm listing the files and folders in my application only.
Please get me some solution for this. Any help will be greatly appreciated.
Thanks in Advance.
Solved the issue when tried the following code:
var driveLogInCallBackCheck = setInterval(function () {
var request =gapi.auth.getToken()
if(request)
{
//Login successful Code here..
window.clearInterval(driveLogInCallBackCheck);
}
}, 250);
Hope it may help someone facing the same issue.