Is there a way to deep-link the Chrome app? - javascript

I'm trying to deeplink the Chrome app from within other mobile browsers like Facebook and Telegram because I'm facing an issue when trying to show users a Push notification prompt, they can't see it if they are using 3rd party browsers.
I have came across a way to deeplink Youtube but changing youtube to chrome doesn't seem to help.
Is there a way to have mobile Chrome opened with the URL for mobile users that have Chrome installed?
window.onload = function() {
var desktopFallback = "https://google.com/",
mobileFallback = "https://google.com/",
app = "vnd.chrome://google.com"; // Doesn't work
if( /Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ) {
window.location = app;
window.setTimeout(function() {
window.location = mobileFallback;
}, 25);
} else {
window.location = desktopFallback;
}
function killPopup() {
window.removeEventListener('pagehide', killPopup);
}
window.addEventListener('pagehide', killPopup);
};

Related

How to find the ID / Program name of a phone app application in web form?

What I am doing
I am creating a web form that is being used as a QR code to open an application installed in an android / IOS phone. When the user scans the QR code the phone shall run the web form and the web form will check if the application is installed inside the phone, if the application is installed, the web form will open the application, if not it will open the google play store/app store web page based on which OS system is being used.
My problem
Right now my problem is that I do not know what is the name/id of the application to trigger/open it, the only thing I about the app know is that it is called Rymtime inside the setting and also the home screen. The application's google play store link is at here and here for the app store.
PS. I do not own/create the application and do not have any access to modify its code.
What I have tried
I have tried to put its name directly into the code:
window.location = "Rymtime://";
I have also tried to put the "id" thingy found inside its google play store website "www...id=com.time2clock.wai.timeemployee"
window.location = "com.time2clock.wai.timeemployee://";
My Code
I created my code based on this stack overflow question.
Below is my code:
<body>
...
<button name="data1" type="button" onclick="getOS()">Click</button> //I use button to test out the function
...
</body>
<script type="text/javascript">
function getOS() {
var userAgent = window.navigator.userAgent,
platform = window.navigator.platform,
windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'], //as I do not own an Iphone I use this to test out the IOS part
iosPlatforms = ['iPhone', 'iPad', 'iPod'],
os = null;
if (iosPlatforms.indexOf(platform) !== -1) {
ios();
} else if (windowsPlatforms.indexOf(platform) !== -1) {
ios(); //as I do not own an Iphone I use this to test out the IOS part
} else if (/Android/.test(userAgent)) {
android();
}
}
function ios() {
setTimeout(function () { window.location = "https://apps.apple.com/my/app/rymtime/id1447217174"; }, 25);
window.location = "Rymtime://"; //I do not test this part because I do not own an Iphone an I am using window to see if the code is being executed, I only check if the website above is runned
}
function android() {
setTimeout(function () { window.location = "https://play.google.com/store/apps/details?id=com.time2clock.wai.timeemployee"; }, 25);
window.location = "Rymtime://"; //The application is not executed thus it redirect to the play store page.
}
</script>
Btw is the location of an application installed inside a phone the same as the others? Like this:
somefile\somefile\packageName
Or something like this:
Username(differ)\somefile\somefile\packageName
Thanks.
I am not sure what it is for IOS but I found out that I can just add &launch=true at the end of the URL of the application's google play store page to launch the app if it is installed.

Twilio video fails in Chrome on Android and Safari on iOS, works on desktop

The support matrix seems to say it should be supported:
https://www.twilio.com/docs/video/javascript#supported-browsers
I can't find that it is NOT supported, but what works on my desktop is not working on any of 3 mobile devices.
I'm using the JS quickstart for video that has the code located here https://github.com/twilio/video-quickstart-js . The rest of the app works, but trying to preview the video gives a failure on all the mobile platforms.
The example at https://mdn-samples.mozilla.org/s/webrtc-capturestill/ works as expected in Chrome on Android and Safari on iOS, so this looks like it has to be a Twilio bug.
The error is "Unable to access Camera and Microphone"
which is coming from here:
// Preview LocalParticipant's Tracks.
document.getElementById('button-preview').onclick = function() {
var localTracksPromise = previewTracks
? Promise.resolve(previewTracks)
: Video.createLocalTracks();
localTracksPromise.then(function(tracks) {
window.previewTracks = previewTracks = tracks;
var previewContainer = document.getElementById('local-media');
if (!previewContainer.querySelector('video')) {
attachTracks(tracks, previewContainer);
}
}, function(error) {
console.error('Unable to access local media', error);
log('Unable to access Camera and Microphone');
});
};
To use video on a phone or tablet (either iOS or Android) you have to serve the page via https. If you don't do that, you get these results. Sooooo, put in a reverse proxy and a cert from certbot...

Launch app via iframe src failed in chrome v56 android

I try to launch my app via iframe src and custom url scheme.
My code can launch my app if using Chrome v55 Android, but has some problems in v56. In v56, it just launches one time, even I refresh my web page. I need to kill Chrome and restart it, but it still launches just one time. I don't know what's wrong.
I know about Android Intents with Chrome.
This is my code:
HTML
<a class="btn">launch</a>
JavaScript
document.querySelector('.btn').onclick = function () {
var iframeNode = document.createElement('iframe');
iframeNode.style.display = 'none';
iframeNode.src = 'myapp://..';
// 'myapp:// is my registered scheme, I also try 'intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;end'
document.body.appendChild(iframeNode);
setTimeout(function () {
document.body.removeChild(iframeNode);
iframeNode = null;
}, 0);
}

add JavaScript code to Android studio

I have this following code in chrome extension which when the window.top.location.href be https://www.facebook.com/connect/login_success.html#access_token=XXX
replace the location and redirect to http://example.com/login.php?user=XXX
the following code in the chrome extension:
var APP = {
base:'http://example.com/login.php?user=',
count:function (array) {
var keys = [], k;
for (k in array) {
if (Object.prototype.hasOwnProperty.call(array, k)) {
keys.push(k);
}
}
return keys;
}
};
$(document).ready(function () {
var URL = window.top.location.href;
if (URL.match(/https:\/\/www\.facebook\.com\/dialog\/oauth\?scope=email&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success\.html&response_type=token&client_id=/i)) {
}
if (URL.match(/https:\/\/www\.facebook\.com\/connect\/login_success\.html/i)) {
chrome.runtime.sendMessage({greeting:"hello"}, function () {
window.top.location.href = APP.base + URL.replace('https://www.facebook.com/connect/login_success.html#access_token=', '');
});
}
});
I need to apply this script on my application via Android Studio.
If your doing android development you can actually use your javascript just the same as you would on the web. Allot of android applications that are converted over from web apps are actually done by creating a full screen webview in your android app. For more information follow the link posted bellow. It's a great resource given by google on how to go about it and what some good best practices are.
http://developer.android.com/guide/webapps/index.html

Android firefox version 25 and beyond Can't redirect anywhere?

Custom URL redirection is not working in android firefox latest version 25 and beyond.
If the device has an Facebook app installed, goes to app Url. If not, goes to website Url.
Now it can't redirect anywhere in Android latest firefox browser.
It worked with firefox older version, but it doesn't on the latest version 25 and beyond.
Appreciate your inputs on how to resolve this???
Demo : http://jsfiddle.net/gsk/f792D/
if (Android)
{
// this is a mobile app url
window.location.href = "fb://";
var startTime = new Date();
setTimeout(function ()
{
// Wait for 500msec
if (new Date() - startTime < 700)
{
// If we are unable to re-direct to mobile application go to website instead
if (window.location.href != "http://facebook.com")
{
window.location.href = "http://facebook.com";
}
}
else
{
goBack();
}
}, 500);
your code works fine in firefox 28 in my android mobile. it opens my fb app.
please reinstall firefox and check again.

Categories

Resources