How to break out of Twitter in-app browser in Android? - javascript

I have a typical modern web-app, regularly shared on Twitter.
I recently noticed that, when opening our web-app in the Twitter internal browser, localstorage is deactivated, which breaks our app.
How could I break out of the Twitter internal browser and open the page in the default Android browser?

I haven't tried this but just a suggestion. You could take a look at this and give it a try.
At the end of the article, it says that the external app won't be invoked if triggered without a user gesture but I believe that the limitation won't be there in case of the In-App browser.

Well, I think it isn't quite easy to say Android via a WebView to open the Chrome Browser as this in-app browser could be a lot different.
What you could try, as mentioned in the article Here is to trigger a click on an anchor which is calling an "pseudo" intent and add the fallback_url .
There isn't much details provided but it could be a possible hack / workaround.
In your HTML
...
And with JS:
$(".open_me").trigger("click");
According to the article
Now the URL will get you to zxing.org if the app could not be found, or the link was triggered from JavaScript without user gesture
(or for other cases where we don’t launch an external application.)
If you're lucky it will open the fallback_url, but as mentioned before it is a WebView which isn't the same as the Chrome Browser, therefore it is possible that nothing happens.

You can use a iFrame in your HTML like this:
<iframe src="url.com" width="900" height=400"></iframe>

Related

Open Android "real" browser when link clicked in embedded/system browser with JavaScript

I'm driving traffic to a landing page with PPC on Twitter. Naturally, when they click on the ad in the Twitter app, it opens "embedded" in Twitter, which is usually WebView, but sometimes some vendor specific browser such as MIUI.
The issue I have is that 1/3rd+ of my traffic is running on Android 10 or earlier, and the Stripe code doesn't work in WebView (but it does work in Chrome on the same devices). So, what I'd like is to write a little bit of JavaScript that detects the OS version, and whether it's one of these system webview browsers instead of the "real" browser, and then insert something like:
"Unfortunately, this browser doesn't support payments. Please open this page in your phone's browser, or click this link".
Where the "click this link" link opens the same page in the "real" browser. Of course, I could just have the rest of the text without the link, but it seems like a better UX to me this way, if it's possible.
There's a similar question from 2015 that indicates it's possible in Java, but I'm not writing an app, this is just a web page, so I'm wondering if it's possible/how to do it in JavaScript.

Is there any way to force a link to open in Chrome from Facebook's in-app browser?

I've got a web app that requires the ability to print. Facebook's in-app implementation of Chrome doesn't allow printing. Currently, I'm giving the user instructions on how to open in chrome themselves in place of the print button I give normal users. But I'd prefer to just open Chrome for them when they get to that page, or at the very least provide a button/link that would open the page in Chrome instead of forcing them to find the settings button and figure out how to open Chrome themselves.
I've tried using the googlechrome://myurl.com approach, and Chrome opens, but the specified url doesn't load.
I've looked into Google's Intent option but I wasn't able to figure out how to open Chrome with that method.
Is there a way to accomplish this in javascript? or by some url scheme in an href attribute?
So far, all the other answers I've found give explanations for how to do this from an Android App, but not from a website.
** Update: The googlechrome://myurl.com seems to work fine from iOS in the native facebook app. It does not appear to work correctly using the native facebook app in Android.
Try
googlechrome://navigate?url=example.com
for Android users.
Reference from https://stackoverflow.com/a/12013755/9514189

How can I detect if the webpage is being rendered in WebBrowser Control?

Most of the people who will access my app will do so from a preinstalled software on their pc that has a browser component built with Microsoft's WebBrowser Control which is just Internet Explorer wrapper.
I want to know if there's a way I can detect, using Javascript, or any other method from inside my website, when it is being rended using this wrapper.
The reason I want to do this is that software was already built and goes to the home page of my site. But I want to redirect them directly to the login screen if they are accessing from that wrapper.
By default the WebBrowser Control uses IE7 so you can check the user agent string (I doubt your other users will be using such an old Internet Explorer version as their browser causing a faulty recognition).
However, this is not a perfect solution, if you can modify the preinstalled software and deliver a new version to people that will be using it you can send a specific header along with the request to determine its origin.
I don't think you can do this accurately. As Samuil stated, you can hack it a bit and maybe catch some of it.
Why not set the default page of your website to be the login page so the user goes to that page regardless?

Instagram iphone hooks

Instagram has some cool hooks that can be used to open the app from a web url.
e.g. instagram://camera
But when a user doesn't have instagram installed, the browser doesn't know how to handle the url. Is there a way for me to detect if the user has instagram installed (in javascript)?
In Objective-C the [[UIApplication sharedApplication] canOpenURL:url] expression may be used to detect whether a URL is handled by any app in the system. If you use PhoneGap or some similar framework, then look for this method. If you have only a webapp, then I'm pretty sure that this is impossible.
The issue with a web app is that it is sandboxed like a web page, it cannot reach outside of the browser. However, it seems to be possible that you can detect the presence with a timing based method. That is, if the app is not installed, the user will return to, or not be able to leave at all the browser within a certain, relatively short time. Thinking along these lines I found this solution: Check if URL scheme is supported in javascript
You may be able to build a solution using this approach, but the "Cannot Open Page" alert box will always be thrown at your users. Though, this IMHO is not really annoying if you handle it correctly on the web app side.
UIApplication has a method canOpenURL: that you can use to check.
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"instagram://camera"]]) {
}

Launch mobile Safari from UIWebView *without* modifying app source?

I'm developing a small site that will only be viewed in-app inside a UIWebView, and one page has several links to an external website. I'd like these to open in mobile Safari, but all links inside the app load within the webview. Modifying the source of the app isn't an option since the site needs to be live before any changes could be submitted.
Is there a way to force a link inside a UIWebView to launch mobile Safari using HTML/5 or Javascript? Mimic shouldStartLoadWithRequest? Sneaky, hacky workarounds or brilliant alternate solutions?
(And, out of sheer curiosity... why not?)
It would be bad design to let sites access the frameworks on the iPhone via simple HTML. This would open up all sorts of security holes. Its not web behavior you want to alter, so I think you may need to change the app source. I still don't understand why that isn't an option. Could you go into more depth?
One option would be to add a custom URL handler. Your website could then determine if the "broswer" is the app and serve custom URLs for those links you'd like to maintain (aka open) in your app. Then, any standard HTTP/s URLs would open in Mobile Safari.
In other words, have your web server provide urls like myappurl:// for the links you'd like your app to handle, and http:// which would open Mobile Safari.

Categories