-
Notifications
You must be signed in to change notification settings - Fork 14
/
redirect.ejs
38 lines (38 loc) · 1.55 KB
/
redirect.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>redirect</title>
</head>
<body>
<p>... redirecting to dev server: <%- lanIp %>:<%- port %></p>
<p>
This screen only shown in development mode.<br>
If your app hangs up on this screen, please check the following.<br>
- The dev server is running properly with `cordova-serve` command.<br>
- Your development PC and the test devices are connected to the same LAN, and also there is no firewall blocking access from the test devices to the PC.
</p>
<script src="cordova.js"></script>
<script>
document.addEventListener('deviceready', function() {
var lanIp = '<%- lanIp %>'
var protocol = '<%- https ? "https" : "http" %>'
var port = '<%- port %>'
var platform = device.platform.toLowerCase()
if (platform === 'amazon-fireos') { // see https://github.com/dekimasoon/vue-cli-plugin-cordova/issues/29
// platform "amazon-fireos" seems to have disapear from Cordova docs, and can't be downloaded anymore.
// In order to avoid asking server for something that doesn't exist, "alias" "amazon-fireos" to simply "android"
platform = 'android'
}
var redirectTo = protocol + '://' + getRedirectIp(lanIp) + ':' + port + '/?_cp=' + platform
window.location.href = redirectTo
})
function getRedirectIp (lanIp) {
if (device.platform === 'Android' && device.isVirtual) {
return '10.0.2.2'
}
return lanIp;
}
</script>
</body>
</html>