2014-08-28 155 views
0

我正嘗試使用棘輪創建簡單的Cordova移動應用程序,但無法獲取push.js以加載任何頁面。我研究的唯一東西是push event only works on mobile devices,但我沒有在瀏覽器中使用它。我試圖通過XCode和CLI中的cordova build ioscordova emulate ios進行模擬,但鏈接不起作用。他們眨眼間表示我點擊了他們,但沒有發生任何行動。這是我想轉換的兩頁。棘輪push.js無法重定向網頁

的index.html

<html> 
    <head> 
     <meta charset="utf-8" /> 
     <meta name="format-detection" content="telephone=no" /> 

     <!-- Set the viewport settings to prevent scaling --> 
     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, target-densitydpi=device-dpi" /> 

     <!-- Makes your prototype chrome-less once bookmarked to your phone's home screen --> 
     <meta name="apple-mobile-web-app-capable" content="yes"> 
     <meta name="apple-mobile-web-app-status-bar-style" content="black"> 

     <title>MyProject</title> 
     <link rel="stylesheet" type="text/css" href="css/index.css" /> 
     <link rel="stylesheet" href="css/ratchet.css"> 
     <meta name="msapplication-tap-highlight" content="no" /> 
     <script src="js/jquery-2.1.1.min.js"></script> 
     <script type="text/javascript" src="cordova.js"></script> 
     <script type="text/javascript" src="js/index.js"></script> 
     <script src="js/ratchet.js"></script> 
     <script type="text/javascript"> 
      app.initialize(); 
      $(function(){ 
       window.localStorage.setItem('phone-number', '1-330-697-3044'); 
      }); 
     </script> 
     <style> 
      /*Stops the text from being in all caps*/ 
      body * { 
       text-transform: none;  
      } 
     </style> 
    </head> 
    <body> 
     <!-- Bar items --> 
     <header class="bar bar-nav"> 
      <h1 class="title">RealtyShout</h1> 
     </header> 
     <nav class="bar bar-tab"> 
      <a href="#" class="tab-item active"> 
       <span class="icon icon-home"></span> 
       <span class="tab-label">Home</span> 
      </a> 
      <a href="subscriptions.html" data-transition="slide-in" class="tab-item"> 
       <span class="icon icon-star"></span> 
       <span class="tab-label">Subscriptions</span> 
      </a> 
      <a href="#" class="tab-item"> 
       <span class="icon icon-person"></span> 
       <span class="tab-label">Contact Info</span> 
      </a> 
      <a href="#" class="tab-item"> 
       <span class="icon icon-download"></span> 
       <span class="tab-label">Messages</span> 
      </a> 
     </nav> 
     <!-- Page contents --> 
     <div class="content"> 
      <ul class="table-view"> 
       <li class="table-view-cell"><a href="subscriptions.html" data-transition="fade" class="navigate-right">Subscriptions</a></li> 
       <li class="table-view-cell"><a href="#" class="navigate-right">Contact Info</a></li> 
       <li class="table-view-cell"><a href="#" class="navigate-right">Messages</a></li> 
      </ul> 
     </div> 
    </body> 
</html> 

subscriptions.html

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <meta name="format-detection" content="telephone=no" /> 

     <!-- Set the viewport settings to prevent scaling --> 
     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, target-densitydpi=device-dpi" /> 

     <!-- Makes your prototype chrome-less once bookmarked to your phone's home screen --> 
     <meta name="apple-mobile-web-app-capable" content="yes"> 
     <meta name="apple-mobile-web-app-status-bar-style" content="black"> 

     <title>MyProject: Subscriptions</title> 
     <link rel="stylesheet" type="text/css" href="css/index.css" /> 
     <link rel="stylesheet" href="css/ratchet.css"> 
     <meta name="msapplication-tap-highlight" content="no" /> 
     <script src="js/jquery-2.1.1.min.js"></script> 
     <script type="text/javascript" src="cordova.js"></script> 
     <script type="text/javascript" src="js/index.js"></script> 
     <script src="js/ratchet.js"></script> 
     <script type="text/javascript"> 
      app.initialize(); 
     </script> 
     <style> 
      /*Stops the text from being in all caps*/ 
      body * { 
       text-transform: none;  
      } 
     </style> 
    </head> 
    <body> 
     <header> 
     <!-- Bar items --> 
     <header class="bar bar-nav"> 
      <h1 class="title">MyProject</h1> 
     </header> 
     <nav class="bar bar-tab"> 
      <a href="#" class="tab-item"> 
       <span class="icon icon-home"></span> 
       <span class="tab-label">Home</span> 
      </a> 
      <a href="#" class="tab-item active"> 
       <span class="icon icon-star"></span> 
       <span class="tab-label">Subscriptions</span> 
      </a> 
      <a href="#" class="tab-item"> 
       <span class="icon icon-person"></span> 
       <span class="tab-label">Contact Info</span> 
      </a> 
      <a href="#" class="tab-item"> 
       <span class="icon icon-download"></span> 
       <span class="tab-label">Messages</span> 
      </a> 
     </nav> 
     <!-- Page contents --> 
     <div class="content"> 
      <ul class="table-view"> 
       <li class="table-view-cell">Hello World</li> 
      </ul> 
     </div> 
     </header> 
    </body> 
</html> 

回答

0

我猜的index.html和subscriptions.html通過文件系統提供服務呢?它意味着它符合你的phonegap/cordova應用程序?這可能是該URL使用file://協議內部編譯的應用程序加載,目前不支持push.js。

我能得到它從@artemave

應用的push.js代碼修改後的版本工作只需更換ratchet.js與此版本的「//核心PUSH功能」部分:

https://github.com/artemave/ratchet/commit/5ccfdd765ecd15666b83b0b9abc15e4c120b7713

解決了ios模擬器中對我的問題。