How do I open any app from my web browser (Chrome) in Android, automatically? - redirect

I am struggling a little bit. I have a common url like www.domain.com/test.html
and i want Android users to get my app open if "test" is included, otherwise if they don't have the app their should be directed to the play store. I got everything implemented and it works with mozilla browser. But using chrome on Android it should be forbidden to automatically open the app if it is available!?. Now if the user enters www.domain.com/test.html and i recognize he is using Android and Chrome i tried the intent stuff in a script in a redirected www.domain.com/android_chrome.html:
<script> window.open("intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http%3A%2F%2Fzxing.org;end","_self")
</script>
But the App won't open automatically. If i use a regular Link:
Take a QR code
it works. But i want to let it open automatically!

Google restricted starting intents from javascript apps, that's why it isn't working. Security reasons I guess. You should just display nice big link to let user switch to your app instead of website - or let him continue if he doesn't want to launch the app.
Forcing users into using app is bad, IMO. Splash screen suggesting to use it is okay, but don't push it.

Related

Flutter, open universal link after redirect for external app

We are developing app for affiliate services, CPA networks gave us marketing links (that customers should use to redirect to web shop), however I can't figure it out, how to trigger universal link to open relevant app after redirect is finished.
For example, CPA network gave as a link to Aliexpress, let it be something like this for example
https://ourcpapartner.com/link/to/aliexpress?params
And we open link with following code using url_launcher
if (await canLaunch('https://ourcpapartner.com/link/to/aliexpress?params')) {
await launch('https://ourcpapartner.com/link/to/aliexpress?params');
} else {
throw ('Redirect failed');
}
With Safari, there are no problems, but with Google Chrome nothing simply happens, after opening that link, it instantly redirects to final url - Aliexpress.com, and now it should open app (if it's installed of course), but nothing is happening, however, once you click on something (e.g product) then app is opened and affiliate tracking is messed up.
It does open app as intented if you click direct link on our website.
I might consider to use WebView instead (so it does not depend on third party browser specifications), but how it would be possible to open local apps then? We can't just hard code every app we need to open with deeplink as we got hundred of different offers.

App Store/Play Store redirection if App is not installed on ionic App

I have implemented deeplink for my ionic v1 application and also implemented universal link for same. I also checked so many links to implement App store redirection functionality.
Most of the link suggest to implement javascript code which first check device and based on ios/adnroid/window it will redirect to particular store but let say I will create that javascript code look like below
const iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
if (iOS) {
window.location.href = "temp://itunes.apple.com/us/app/...";
}
but where should I put this file so when user click on deeplink it should redirect to particular this file and redirect to App Store/Play Store?
Let say I want to give my deeplink to some other server for which i don't have any access then what?
is there any other param or attribute we can set like fallback url by which when app is not installed it will automatically going to that particular link?
Any answer would be great help.
Thanks.
Usually it works that way:
You place a link on the website where you want to advertise your app. That link has a click tracking domain that points to your server. e.g. click.example.com/....
Upon clicking, if the app is installed, Universal Links would ensure that the app is opened. This is done by iOS (only if you configured Universal Links correctly, see https://developer.apple.com/ios/universal-links/). If the app is not installed, a redirect is done to your click tracking domain. This is where your Javascript logics should apply, so basically you need to reply to the request with a 302 redirect to an HTML file that contains the redirection logics (as in the example above). In that server response you can handle any fallback URL you want to use.
By the way, to make Universal Links work, anyway you had to host the AASA file, so you probably already created a server, so you can use it for the case where the app is not installed.

How to debug on Facebook Internal Browser (Mobile)?

I'm developing website with a lot of HTML5 and CSS3 features. I'm also using iframe to embed several content on my website. It works fine if I open it using Chrome/Firefox/Safari mobile browser. However, if I share on facebook (post/page) and I opened it up with Facebook application with Facebook Internal Browser, my website is messed up.
Is there any tools or way to debug on Facebook Browser? Thanks.
This is how you can do the debugging yourself. It's painful, but the only way I've come across so far.
tl;dr Get the Facebook App loading a page on your local server so you can iterate quickly. Then print debug statements directly to the page until you figure out what is going on.
Get a link to a page on your local server that you can access on your mobile device (test in mobile safari that it works). See this to find out your local IP address How do you access a website running on localhost from iPhone browser. It will look something like this
http://192.xxx.1.127:3000/facebook-test
Post that link on your Facebook page (you can make it private so your friends aren't all like WTF?)
Click the posted link in the Facebook mobile App and it will open up in Facebook's mobile browser
Since you don't have a console, you basically need to print debug statements directly to the page so it is visible. Put debug statements all over your code. If your problems are primarily related to CSS, then you can iteratively comment out stuff until you've found the issue(s) or print the relevant CSS attributes using JavaScript. Eg something like (using JQuery)
function debug(str){$('body').append("<br>"+str);}
Quite possibly the most painful part. The Facebook browser caches very aggressively. If you are making changes and nothing has happened, it's because the content is cached. You can sometimes resolve this by updating the URLs, eg /facebook-test-1, /facebook-test-2, or adding dummy parameters eg /facebook-test?dummy=1. But if the changes are in external css or js sheets it sometimes will still cache. To 100% clear the cache, delete the Facebook App from your mobile device and reinstall.
The internal browser the Facebook app uses is essentially a uiWebView. Paul Irish has made a simple iOS app that lets you load any URL into a uiWebView which you then can debug using Safari's Developer Tools.
https://github.com/paulirish/iOS-WebView-App
I found a way how to debug it easier. You will need to install the Ghostlab app (You have a 7-day free trial there, however it's totally worth paying for).
In Ghostlab, add the website address (or a localhost address) you want to debug and start the session.
Ghostlab will generate a link for access.
Copy that link and post it on Facebook (as a private post)
Open the link on mobile and that's it! Ghostlab will identify you once you open that link, and will allow you to debug the page.
For debugging, you will have all the same tools as in the Chrome devtools (how cool is that!). For example, you can tweak CSS and see the changes applied live.
If you want to debug a possible error, you can try to catch it and display it.
Put this at the very top of your code:
window.onerror = function (msg, url, lineNo, columnNo, error) {
var string = msg.toLowerCase();
var substring = "script error";
if (string.indexOf(substring) > -1){
alert('Script Error: See Browser Console for Detail');
} else {
var message = [
'Message: ' + msg,
'URL: ' + url,
'Line: ' + lineNo,
'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error)
].join(' - ');
alert(message);
}
}
(Source: MDN)
This will catch and alert your errors.
Share a link on Facebook (privately), or send yourself a message on Facebook Messenger (easier). To break the cache, create a new URL every time, e.g. by appending a random string to the URL.
Follow the link and see if you can find any errors.
With help of ngrok create temporary http & https adress instead of your ordinary localhost:3000(or other port) and you could run your app on any devices. It is super easy to use.
and as it was written above all other useful information you should write somewhere inside div element (in case of React I recommend to put onClick on that div with force update or other function for getting info, sometimes it helps because JS in FB could be executed erlier than your information appears). Keep in mind that alerts are not reliable, sometimes they are blocked
bonus from ngrok that in console you will see which files was
requested and response code (it will replace lack of network tab)
and about iFrame.If you use it on other domain and you rely on cookies - you should know that facebook in-app browser blocks 3rd party cookies
test on Android and iOS separately because technicaly they use different browsers

Possible to open iPhone Safari and target a specific window?

I have an app that uses OAuth to authenticate, which means the user must be directed to the website to authorize the application. I prefer to make it obvious to the user that they are using a standard browser to authorize at the original site rather than just using a web view to show the content within my app. However, every time they are directed to Safari (via openURL), it launches a new Safari window and once Safari has 8 windows open, it simply fails to work at all.
I'm wondering if there is an equivalen to the "target" attribute of an anchor tag in html which would allow me to cause all openURL calls from my application to open in the same window.
There is other functionality that I can expose via the web application, creating a hybrid app between native iphone functionality and web app functionality in Safari, but if I have to launch a new window every time I switch between the app and Safari, it becomes unworkable. The Youtube app is obviously able to return the user to the previous page after showing a video, but that might well be a custom plugin in Safari for iphone. Also, while returning to the previous page is somewhat useful, sending them to a new URL in the existing window really opens up a lot of possiblities.
I'm pretty sure there is no way to pass a target parameter to openURL:.
What I noticed about Safari is that it won't open another tab if the page you are opening with openURL: is/was already open in Safari. It just reloads that page. This might sound trivial and not helpful but perhaps you could use it to your advantage if you can make your web application only use one page. Different views or states could be expressed with #anchor tags.
An example is http://m.flickr.com. Notice their URL structure? It goes http://m.flickr.com/#/home, http://m.flickr.com/#/explore/interesting/, http://m.flickr.com/#/search and so on. All of these are different web pages to the user but to Safari it's all the same page.
I found iOS 6.0.1 Safari will open the same tab with a simple hashtag, without the slashes. So with the above example http://m.flickr.com, openURL to http://m.flickr.com#someinfo opens to the same tab.
In your webpage, use window.location.hash to return the params. In the above example it will return #someinfo.

How do I embed openads (Openx) ads in an iPhone application

I have tried using iframe, javascript and image tag Ad tags in iPhone application, but none of them work. When a user clicks on an image, the browser is launched but then nothing happens (you get a blank page). Anyone know how to proceed?
To proceed: debug it. A standard OpenX click URL will do a redirect. What URL is the browser sticking at?
I don't know anything about iPhone applications, but I do know about interfacing to OpenX. You possible should consider using the OpenX API, which will allow you to pull all the information you need into the 'back end' of your application, then use it as you need.
Proplem in iphone must be active enable java in iphone safari settings