zoukankan      html  css  js  c++  java
  • php页面判断是 iphone还是andriod的浏览器&通过 URL types在浏览器打开app(转)

    http://blog.csdn.net/totogo2010/article/details/8925483

    解决一个二维码不同手机扫描下载时跳转的问题

    判断后跳转对应的app下载

    [php] view plain copy
     
    1. <?php  
    2.   
    3.     $agent = strtolower($_SERVER['HTTP_USER_AGENT']);   
    4.     $iphone = (strpos($agent, 'iphone')) ? true : false;   
    5.     $ipad = (strpos($agent, 'ipad')) ? true : false;   
    6.     $android = (strpos($agent, 'android')) ? true : false;   
    7.     if($iphone || $ipad)  
    8.     {  
    9.         echo  <<<END  
    10.         <script>window.location.href='itms-apps://itunes.apple.com/cn/app/zhong-guo-tou-zi-zhi-nan/id644856699?mt=8'</script>  
    11. END;  
    12.     }   
    13.     if($android){  
    14.         echo "<script>window.location.href='http://www.anzhi.com/dl_app.php?s=803308'</script>";  
    15.     }  
    16.     ?>  



    类似微信app分享时,直接通过浏览器内核启动app是如何做到的呢?

    那在iphone中浏览器启动app是如何做到的呢?一共三步

    在info.plist里添加 URL types 属性,如下图:

    在 AppDelegate里添加代码:

    [cpp] view plain copy
     
    1. - (void)showMsg:(NSString*)msg{  
    2.     UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"tips"  
    3.                                                  message:[NSString stringWithFormat:@"Schemes url :“%@”",msg]  
    4.                                                     delegate:self  
    5.                                            cancelButtonTitle:@"确定"  
    6.                                            otherButtonTitles:nil];  
    7.     [alertView show];  
    8. }  
    9.   
    10. -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{  
    11.     if(!url){  
    12.         return NO;  
    13.     }  
    14.       
    15.     NSString *urlString=[url absoluteString];  
    16.     [self showMsg:urlString];  
    17.     return YES;  
    18. }  

    在浏览器里输入:

     

  • 相关阅读:
    PHP小技巧
    PHP Ajax跨域解决
    单点登录
    Linux 常用命令
    php面向对象--继承
    vueDemo
    vueSource
    vuex
    Vue.js
    关于前后端分离
  • 原文地址:https://www.cnblogs.com/kenshinobiy/p/5531226.html
Copyright © 2011-2022 走看看