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.
Related
I need two pages to be open at once when the user clicks on an image that is being sent in an email message.
I tried to use window.open but when the message is sent to the recipient the link on the image does not work.
Could you help me or tell me a better way to make this possible??
The code:
<img width="500" align="center" src="img_1">
Within email app, it's not possible. As Quentin mentioned above, all of the email consumption software, including Outlook, webmail and iPhone native email app will block your JavaScript in the message.
However, in theory, the result could be achieved using an intermediary landing page, which would perform the all the JS you need, opening two tabs.
I once had a similar project where we implemented intermediary landing page that sniffed the user agent and redirected to the deep-linked mobile website or a different desktop landing page. For example, you would link to your landing page like:
http://yourlandingpage.com?tab1toopen=http://page1.com&tab2toopen=http://page2.com
This raises new issues around:
* URL tracking (and automating encoding and/or optional URL shortening and admin of all of this),
* URL length (which is limited on Windows desktop Outlook clients),
* security of that landing page (lander should sanitize the strings, maybe even do some secret hand-shaking via unique encrypted var), and,
* can it sustain the heavy traffic (which is larger problem that it appears if you work with big brands).
Due to major security issues, scripting is not available in emails. Many clients will strip the scripting completely while others can mark it as spam or block it entirely.
Your best bet would be to have it link to a static landing page that then runs a script to open the two windows for you.
http://javascript.about.com/od/reference/a/jsemail.htm
Some other good sources on what is allowed and not allowed in HTML email:
http://kb.mailchimp.com/campaigns/design/limitations-of-html-email
http://kb.mailchimp.com/templates/code/common-html-mistakes
https://www.campaignmonitor.com/dev-resources/guides/coding/
How about this?
HTML
<img width="500" align="center" src="img_1">
JS
<script type="text/javascript">
function DoThis() {
window.open('http://www.foo.com', _blank); //open link 1 in new tab
window.open('http://www.g1.com.br', _blank); //open link 2 in new tab
}
</script>
This applies both to Android and iOS. My web page may be sometimes opened by an app (you go to the app, and click a link there which opens the page).
I want to know if the page was accessed through an app or if the user got to it, let's say, by typing the address on the browser.
If accessed through an app, I don't need to know which app it was.
The only thing I know of is document.referrer, but it seems to return "" when the page has been opened by the app. Unfortunately using "" as an indicator is not possible, as other ways of getting to the page may also show "" (for example typing the address). The history object does not seem to contain the info I'm looking for either.
I am using a Zendesk Help Center, so I only have access to the javascript of the page in order to detect this. I can't make changes on the server-side of my page.
Alternatively, I may be able to talk to the people in charge of the app so that they include something when the app opens the browser which would allow me to access that info on the browser, but I am not sure what that could be. Any ideas?
Thank you!
It seems to me like your best bet would be to have specific links for your site that will let you know that the link came from the app.
Like so: http://www.yoursite.com/?openedFromApp
You will use those links inside the app that will be directing users to your website.
That way, if you were using PHP as your server-side language you'd be able to check if the openedFromApp URL parameter was set like so:
<?php
if(isset($_GET['openedFromApp'])) {
echo "The website was opened by an app";
}
else { echo "The website was opened normally"; }
?>
If you want to check if the openedFromApp URL parameter is set using Javascript you'd have to create your own function for accessing URL parameters as Javascript does not have a built-in way of accessing them.
But this link could help you access the URL parameters with Javascript: https://stackoverflow.com/questions/...
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.
Let's say I have a mobile app that listens to all "myawesomeapp" scheme links so it can open them in the app and I have a related website. Now when a page, for eg, https://myawesomeapp.com/home/ is loaded in the browser, I create an iframe dynamically and add it to the document with the src of myawesomeapp://myawesomeapp.com/home/ so that my app can try and open up that page within itself. But most modern browsers will display an insecure/mixed content warning when such a link is created from a page served over HTTPS. Is there a way around this behaviour?
Browser can't guarantee that the protocol myawesomeapp is secure (like https). So as a security consideration, it MUST warn the user that insecure content is being loaded in an otherwise secure page.
You can create a service on server to redirect to another scheme. i.e. https://website.com/deeplink/appscheme/path will redirect browser to appscheme://path.
According to this the iframe src trick doesn't work anymore.
If you want your app to automatically trigger upon landing on a web page, I found putting this that web page's <head> tag works:
<meta http-equiv="refresh" content="0; url=myprotocol:/path1" />
Where myprotocol is the "scheme" in your intent filter.
However, I am not sure if this method will also be "blocked" future versions of the browser. As the link above stated:
you should implement a user gesture to launch the app via a custom scheme, or use the “intent:” syntax
It seems to me they want intents to be triggered only by user-initiated gestures such as clicking a button, or a link. There could be security issues if a webpage can trigger intents on its own.
I guess what you want is if the user clicks a link to your site, he gets the option to open the link in your app instead of in the browser.
The way to do this in Android is registering an intent filter so your app gets launched when the user clicks a link to your domain name.
See the example intent filter here:
https://developer.android.com/guide/components/intents-common.html#Browser
This is better than using a custom scheme because the link will lead the user straight to the app, instead of loading the site in a browser which will then open the app.
This works different than in iOS, yes. To keep both compatible, you could sniff the useragent and show the iframe with the custom scheme only in iOS browsers.
Can you try this code out? Call it when the document is ready and pass to it the url of your app.
var redirect = function ( location )
{
var iframe = $('<iframe></iframe>').attr( 'src', location ).css({
width: 1,
height: 1
});
$( 'body' ).append( iframe );
iframe.remove();
iframe = null;
};
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).