Send email navigating future location Waze API - javascript

I wanted to ask whether there is a possibility that I'll email a link that will be pressed on through the Smartphones, the waze will open with a specific address. I saw the page http://www.waze.co.il/dev/documentation/ browser and tried to access the address of Smartphones with this and he did not respond to it (opens a Google search - Android).
Is there such a way? (Basically emulate sharing app gives place).

You can open the browser with this url (from Weze API):
With JavaScript:
document.querySelector('span').onclick = function() {
location.href = 'waze://?q=<address search term>';
}
<span>Navigate</span>
With html:
Navigate
I'll email a link that will be pressed on through the Smartphones
You can just send an email with the link to waze://?q=<address search term>

You can not, at the moment.
That API is for in-app use only (Android & iOS).

Related

Prevent a URL/webpage from opening in application

I have an application which supports all urls having xyz as domain.
So now if I sent my users a message or a mail containing the link of the above domain like xyz.com/abc or maybe xyz.com, for mobile IOS users the link opens in browser but for mobile android users there is a pop up which asks the user to choose whether they want to open the link in my app or the browser.
I have an issue with what the android is doing. I don't want that pop up for some particular links, I want that link to open in browser instead of the application. Is there a way I can achieve it by setting some headers in the response or maybe setting some meta tags in the html.
Thanks in advance for the help!!
You can get you domain host from the URL:
Uri url = Uri.parse("www.xyz.com/lol");
String host = url.getHost();
if (host.equals("xyz.com")) {
openInAppMethod();
} else {
openInBrowserMethod();
}
And then choose the way to open your url.

How to prevent Facebook in app browser from opening my website links?

I'm developing web app and I share my contents using Facebook, the issue I'm facing is when someone clicks on the link posted on Facebook sometimes it opens using Facebook in app browser and that causes many issues.
Is there a way to prevent Facebook from opining my links and use the device default browser instead?
I couldn't get my js dynamic grid to run in the Facebook in-app browser, but I couldn't just leave it up to the user to figure out what was wrong and that they needed to open in a real browser.
I used js to detect the Facebook in-app browser and tried using a js alert to inform the user that they needed to 'open in safari', but alerts don't work consistently or reliably with the Facebook in-app browser.
I found that a redirect to a user alert page was the most reliable solution. It can be presented as you wish (modal, etc.) A code sample for the redirect is included. Note that the redirect page remains within the Facebook browser - only user interaction can break out. I used my redirect page to tell people to use the 'share > open in Safari' function.
When the user clicks on 'open in safari', the redirect page reloads in safari, detects that it is now NOT in the Facebook in-app browser, and automatically redirects the user back to the page they wanted in the first place, but no longer from within the Facebook in-app browser. A "one-click" workaround to get the user out of that in-app browser.
The best solution would still be for my js grids to 'just work' in the Facebook browser some day. If anyone figures it out, let me know.
<!-- check if running in facebook app -->
<script>
var ua = navigator.userAgent || navigator.vendor || window.opera;
function isFacebookApp() {
return (ua.indexOf("FBAN") > -1) && (ua.indexOf("FBAV") > -1);
}
if (isFacebookApp()) {
window.parent.location.assign("https://yourdomain.com/redirect_page/index.html");
}
</script>
It is completely up to the user, there is no way to force opening it in the default browser instead. There is more information (and some answers) in this thread: File upload control not working in Facebook In-App Browser
OR... be less complicated. Why have a function called isFacebookApp() at all, and why target Opera when you are looking only for the FB in-app browser only?
<script>
var ua = navigator.userAgent;
if (ua.indexOf("FBAN") != -1 || ua.indexOf("FBAV") != -1) {
if (!window.location.href.match('redirect_fb')) {
window.location.href = "https://example.com/redirect_fb";
}
}
</script>
Thank you to both of you though. This was driving me nuts. My main problem was fonts being enlarged on my Android. Now I find reducing with a fontsz = Math.round(fontsz*.7)is perfect to counteract (when FB app detected)
Based on Mcbeese
<!-- check if running in facebook app -->
<script>
var ua = navigator.userAgent || navigator.vendor || window.opera;
function isFacebookApp() {
return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1);
}
if (isFacebookApp()) {
if (!window.location.href.match('redirect_fb')) {
window.location.href = "https://example.com/redirect_fb";
}
}
</script>
I found that Android will open Firebase Dynamic Links by external browser regardless of which kind of webview the url was posted.
I wrote a more detailed description at https://stackoverflow.com/a/56143217/3000586.

javascript mailto not working in chrome mobile browser

mailto via javascript not working in mobile chrome browser
window.location.href = "mailto:linto.cet#gmail.com?subject=subject&body=body"
is not working in mobile google chrome browser
actual source
Chrome on Android is blocking the redirects to apps that are not made via a user gesture.
So via javascript it's not possible to redirect the user to the mail app since Chrome 40, only if you put it for example in a button href, that will work when user clicks the button.
You can read more in chromium forum
If you inspect the Chrome console you will a warning, something like: Navigation is blocked: mailto:?...
I am posting an answer as this is possible.
Create a hidden from view / temporary link element and simulate the click.
var linkElement = document.createElement('a');
linkElement.style.visibility = 'hidden';
linkElement.style.position = 'absolute';
linkElement.href = 'mailto:linto.cet#gmail.com?subject=subject&body=body';
document.body.appendChild(linkElement);
and later when you want to trigger and open the mail client:
linkElement.click();
On my site, when people click on what they believe to be mailto links (same restrictions apply on tel: links, by the way), I first send a GA event, and then use window.location to initiate the mailto. While Chrome will give me the warning via the dev console, it still processes the tel/mailto request, and the window still pops up.

Opening SMS editor from web application

I'm looking for a solution which allows me to open native SMS editor from web-page. Body of the message has to be prepopulated and receiver's phone number has to be empty.
There are plenty of suggestions here in stackoverflow to just format anchor or redirect via javascript but unfortunately these solutions are outdated and either do not work as is or are stripped for security reasons.
I've tested following formats on various platforms, but unfortunately they don't work on all devices. I'm looking for an universal solution or library to fulfill the requirements I mentioned.
Send SMS
Send SMS
Used to work on IOS devices but doesn't work anymore. Apparently pre-filled body only works if you supply a phone number which you have in your contacts.
Send SMS
Send SMS
Works on most android devices. Opens up SMS editor, but only some versions allow prepopulated body.
Windows Phone doesn't seem to do anything.
I'm starting to wonder if this is just an endless swamp of compability issues. Technology which the web application is built-on is ASP.NET MVC 5.
100% working
// for andriod
if(navigator.userAgent.match(/Android/i)){
window.open('sms://1900/?body=encodeURIComponent('sms body......'),'_blank')
}
// for IOS
if(navigator.userAgent.match(/iPhone/i)){
window.open('sms://1900/&body=encodeURIComponent('sms body......'),'_blank')
}
replace 1900 with the number you want to send message
Body = sms body
credit goes to :- https://codepen.io/gil--/pen/KMaRmp
This works on iOS 8 (verified):
<p>Open SMS.</p>
<script>
$('#myLink').click(function () {
window.open('sms:&body=My%20text%20for%20iOS%208', '_self');
return false;
});
</script>
This should works on iOS 5,6:
<p>Open SMS.</p>
<script>
$('#myLink').click(function () {
window.open('sms:;body=My%20text%20for%20iOS%205', '_self');
return false;
});
</script>
Notice sms:& for iOS 8, sms:; for iOS 5,6 (and sms:? for Android).
Remember to encode the text after body=
Source: julianklotz
If you want to populate the body but not the phone number this works for both android and IOS8+
thisisthelink
the key is: "sms:?&"
It's not possible to add text, you can only add phone numbers so that
sms link
opens the messaging app.
Apps can register for custom protocol schemes to be called, when a request with such a url was made. But as far as I understand your solution is a pure web application, so the answer is no, it's not possible.

Open google play details page for an app via javascript redirect from android browser

I want my website to redirect to a specific app in the Google Play Market if it is opened on an android device. I followed the instructions on http://developer.android.com/guide/publishing/publishing.html:
"Display the details screen for a specific application: http://play.google.com/store/apps/details?id=<package_name>".
Works great with a link the user is actively clicking on:
Download app
But if I am detecting the device with javascript and trying to redirect the browser automatically changes the http://... to https://... and the user is redirected to the Google Play website instead of the Google Play app on the phone.
if(navigator.userAgent.toLowerCase().indexOf("android") > -1) {
if(confirm("Download app?")) {
window.location.href= "http://play.google.com/store/apps/details?id=<package_name>";
}
}
Is there any way to change this behavior, my test device is a Samsung Galaxy with android 2.3.3?
This seems to work. The redirect opens the Google Play app while using the default browser, but translates the link to https:// play.google... when using chrome
if(navigator.userAgent.toLowerCase().indexOf("android") > -1) {
if(confirm("Download app?")) {
window.location.href= "market://details?id=<packagename>";
}
}
If you want to redirect to Google Play app try doing it from the server.
Client side attempts will not work.
PHP example
header("Location: market://details?id=com.your.app");
If the accepted answer does not work or fails to open in Chrome with this error
ERROR: ERR_UNKNOWN_URL_SCHEME
Change the window.location.href to window.location like this
if(navigator.userAgent.toLowerCase().indexOf("android") > -1) {
if(confirm("Download app?")) {
window.location= "market://details?id=<packagename>";
}
}

Categories