I'm running a captive portal, target audience are mobile devices only. I would like to open a "welcome page" to the user after he authenticated in the CNA. This page should open in (mobile) Safari, not in the CNA, because it contains interactive elements that don't work in the limited CNA environment.
I've seen this working at other portals before, but I don't know how they do it and can't figure out how even after long research.
What I have is:
What I want is:
or
Nothing I found so far (e.g. using target="_system" was mentioned) works. Does anyone know how these hotel and other portals that somehow manage to do it, do it?
You cannot make the OS (OS X or iOS) to open Safari. When iOSX detects a walled garden (captive portal), it launches CNA. That is.
CNA ≠ Safari.
Let's try <a href="..." target="_blank">test</a>
Any try to open another CNA window fails.
Let's try <a href="..." target="_system">test</a>
Any try to open Safari fails (_system works only for Safari, Mail & Safari webviews in iOS applications)
To me: answer = IMPOSSIBLE .
But I wonder: Is there anyone who has already seen this phenomenon. Have you ever Seen a safari page automatically launched after having been presented the CNA window ?
Another bug is introduced in iOS 11 such that CNA will not close itself after opening the link in Safari.
Refer to the discussion here: https://forums.developer.apple.com/thread/75498#221482
The secret is sending an HTML response to the iOS client with a BODY element that contains only the word "Success". The iOS CNA expects something like http://www.apple.com/library/test/success.html to be returned.
For example: Success Success
You can redirect the iOS CNA window using javascript:
<script type="text/javascript">
window.location.href = "yourdomain.com/welcome.html";
</script>
Additionally, you can hide the "Success" message by changing the body text to white with a STYLE attribute on the BODY tag. The iOS CNA application doesn't seem to be looking for a page that exactly conforms to Apple's success.html. It seems to be looking for a BODY element that contains the word "Success".
The captive portal I am using requires that the user agree to the terms of service. The mobile device will detect the captive portal with their CNA (Captive Network Assistant) and open the OS-level browser window with the captive portal login page.
When the user clicks on "Agree & Connect" a form is POSTed which performs the authorization of their MAC on the captive portal appliance.
The webserver returns my own success.html with the white text and the javascript redirect to either the URL requested by the user (for those cases where the user is manually browsing to a website using their mobile browser) or the branded welcome page.
User connects to the captive portal
Mobile device detects the captive portal
Mobile CNA loads the captive portal login page
User clicks "Agree & Connect", issuing a POST request to my webserver which performs authentication
HTTP 302 redirect is returned from the POST URL pointing to a success.html on my webserver which contains a javscript redirect after the BODY element This triggers the iOS CNA web view to detect that it has successfully connected to the network
CNA login window is redirected to my branded welcome.html
CNA webview window automatically closes in Android or the user can click "Done" on the iOS CNA webview window to close it
I managed to get my iOS 9.1 Device to redirect in a mikrotik environment by doing the following:
change the alogin.html page (your connected page) to have a title of connected and a body of connected like so :
<html>
<head>
<title>Success</title>
</head>
<body>
Success
<script>
function addElement(absoluteurl)
{
var anchor = document.createElement('a');
anchor.href = absoluteurl;
window.document.body.insertBefore(anchor, window.document.body.firstChild);
setTimeout(function(){ anchor.click(); }, 1000);
// document.body.appendChild(elemDiv); // appends last of that element
}
addElement("http://www.google.com");
</script>
</body>
on newer devices 10.3.1 this seems to no longer work, currently testing variations of it. https://forums.developer.apple.com/thread/75498
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With