2012-11-17 2 views
1

해당 앱이 설치된 휴대 기기를 탐색하는 경우 기본 IOS 앱을 실행하는 코드/링크를 찾고 있는데 사용하지 않는 경우 웹 기반 URL로 다시 리디렉션합니다. 모바일 기기 또는 앱 (facebook, youtube 등)이 설치되어 있지 않은 경우 fb : // action /을 통해 네이티브 앱을 시작할 수 있지만 fb 앱이 설치되어 있지 않은 경우 웹 기반 페이지로 다시 리디렉션하는 방법을 알아낼 수 없습니다. 나는 어떤 상상력의 스트레칭으로 프로그래머가 아니지만, 나는 며칠 동안 읽고 너무 많이 배웠습니다! 이것에 대한 통찰력은 나에게 많은 것을 의미 할 것이다.휴대 기기에서 브라우징하지 않을 경우 웹 기반 URL로 리디렉션

답변

1

당신은 거기서 프로그래밍을 할 수 없을 것입니다. 브라우징 장치가 모바일인지 여부와 같은 깔끔한 것들을 할 수있는 서버 측 스크립팅 언어 인 php와 리디렉션과 같은 작업을 필요에 따라 수행합니다.

한 번 인터넷에서 뭔가를 발견했습니다. 나는 그것이 당신의 필요에 맞을 수 있도록 그것을 조정했습니다. 의견은 모든 것을 설명해야합니다.

<?php 
    // Get the user agent 
$user_agent = $_SERVER['HTTP_USER_AGENT']; 

// Create an array of known mobile user agents 
// Most mobile devices send a pretty standard string that can be covered by 
// one of these. I believe I have found all the agents (as of the date above) 
// that do not and have included them below. If you use this function, you 
// should periodically check your list against the WURFL file, available at: 
// http://wurfl.sourceforge.net/ 


$mobile_agents = Array(
    "240x320", "acer", "acoon", "acs-", "abacho", "ahong", "airness", "alcatel", "amoi",  "android", "anywhereyougo.com", "applewebkit/525", "applewebkit/532", "asus", "audio", "au-mic", "avantogo", "becker", "benq", "bilbo", "bird", "blackberry", "blazer", "bleu", "cdm-", "compal", "coolpad", "danger", "dbtel", "dopod", "elaine", "eric", "etouch", "fly " , "fly_", "fly-", "go.web", "goodaccess", "gradiente", "grundig", "haier", "hedy", "hitachi", "htc", "huawei", "hutchison", "inno", "ipad", "ipaq", "ipod", "jbrowser", "kddi", "kgt", "kwc", "lenovo", "lg ", "lg2", "lg3", "lg4", "lg5", "lg7", "lg8", "lg9", "lg-", "lge-", "lge9", "longcos", "maemo", "mercator", "meridian", "micromax", "midp", "mini", "mitsu", "mmm", "mmp", "mobi", "mot-", "moto", "nec-", "netfront", "newgen", "nexian", "nf-browser", "nintendo", "nitro", "nokia", "nook", "novarra", "obigo", "palm", "panasonic", "pantech", "philips", "phone", "pg-", "playstation", "pocket", "pt-", "qc-", "qtek", "rover", "sagem", "sama", "samu", "sanyo", "samsung", "sch-", "scooter", "sec-", "sendo", "sgh-", "sharp", "siemens", "sie-", "softbank", "sony", "spice", "sprint", "spv", "symbian", "tablet", "talkabout", "tcl-", "teleca", "telit", "tianyu", "tim-", "toshiba", "tsm", "up.browser", "utec", "utstar", "verykool", "virgin", "vk-", "voda", "voxtel", "vx", "wap", "wellco", "wig browser", "wii", "windows ce", "wireless", "xda", "xde", "zte" 
); 

// Pre-set $is_mobile to false. 

$is_mobile = false; 

// Cycle through the list in $mobile_agents to see if any of them 
// appear in $user_agent. 

foreach ($mobile_agents as $device) { 

    // Check each element in $mobile_agents to see if it appears in 
    // $user_agent. If it does, set $is_mobile to true. 

    if (stristr($user_agent, $device)) { 

     $is_mobile = true; 

     // break out of the foreach, we don't need to test 
     // any more once we get a true value. 

     break; 
    } 
} 
//check whether mobile is true, and if so, redirect to mobile page 
if($is_mobile){ 
    header("Location:http://www.mobilepage.com"); //replace domain 
    exit; 
}else{ 
    header("Location:http://www.notmobilepage.com"); //replace domain 
    exit; 
} 
?> 

다른 대안을 보여주는 this도 참조하십시오.

관련 문제