Usar HTTP_USER_AGENT para distinguir iOS, Windows Phone e Android
Ola Pessoal,
A idéia do código abaixo é levar quem acessa via smartphone para a loja do aplicativo respectivo
Estou usando o HTTP_USER_AGENT para distinguir o sistema. Isso é adequado ? ou tem coisa melhor ?
Para Android funciona 100%
Agora preciso descobri como redirecionar para windows phone 8.1 ou anterior ... e outro link para windows phone 10
Ainda não tenho app para iOS
Agradeço quem puder me ajudar
Marcos
www.conteudoanimal.com.br
<%
Function isMobile()
Dim sys : sys = "android"
v = InStr(lCase(Request.ServerVariables("HTTP_USER_AGENT")),sys)
if v <> 0 then : isMobile = true : exit function : else : isMobile = false
End function
if isMobile() then
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "https://play.google.com/store/apps/details?id=com.Conteudo_Animal"
End if
Function isMobile2()
Dim sys : sys = "windows phone OS 10"
v = InStr(lCase(Request.ServerVariables("HTTP_USER_AGENT")),sys)
if v <> 0 then : isMobile2 = true : exit function : else : isMobile2 = false
End function
if isMobile2() then
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "https://www.microsoft.com/store/apps/9nblggh6b771"
End if
Function isMobile3()
Dim sys : sys = "Windows Phone 8"
v = InStr(lCase(Request.ServerVariables("HTTP_USER_AGENT")),sys)
if v <> 0 then : isMobile3 = true : exit function : else : isMobile3 = false
End function
if isMobile3() then
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://windowsphone.com/s?appid=9ff644d3-fc1d-438d-bb57-5ec25364b5f7"
End if
Function isMobile4()
Dim sys : sys = "Windows Phone 7"
v = InStr(lCase(Request.ServerVariables("HTTP_USER_AGENT")),sys)
if v <> 0 then : isMobile4 = true : exit function : else : isMobile4 = false
End function
if isMobile4() then
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://windowsphone.com/s?appid=9ff644d3-fc1d-438d-bb57-5ec25364b5f7"
End if
%>
Discussão (1)
Carregando comentários...