2013-02-06 40 views
1

當嘗試在使用Phonegap 2.3.0的Xcode 4.6中使用navigator.notification.alert()時,我遇到一個奇怪的問題。iOS notification.alert()無法使用Phonegap 2.3.0

我有兩個文件,index.html和other.html。點擊index.html中的'測試警報'會按預期觸發警報,但在關閉警報並導航到other.html後,單擊'測試其他警報'不會觸發警報。

但是,如果您在移至other.html之前單擊index.html上的兩次或多次「測試警報」,警報將繼續按預期運行。只有在觸發警報ONCE和更改頁面後,警報纔會一起運行。

的index.html

<!DOCTYPE html> 
<html> 
    <head> 
     <script type="text/javascript" src="cordova-2.3.0.js"></script> 
     <script type="text/javascript" charset="utf-8"> 
      function alertTest() { 
       navigator.notification.alert('Testing', null, 'Alert Test', 'OK'); 
      } 
     </script> 
    </head> 
    <body> 
     <a href='other.html'>Move to other page</a> 
     <a href="#" onclick="alertTest(); return false;">Test the alert</a> 
    </body> 
</html> 

other.html

<!DOCTYPE html> 
<html> 
    <head> 
     <script type="text/javascript" src="cordova-2.3.0.js"></script> 
     <script type="text/javascript" charset="utf-8"> 
      function alertTest() { 
       navigator.notification.alert('Testing', null, 'Alert Test', 'OK'); 
      } 
     </script> 
    </head> 
    <body> 
     <a href="index.html">Go back</a> 
     <a href="#" onclick="alertTest(); return false;">Test the alert</a> 
    </body> 
</html> 

我完全茫然,爲什麼出現這種情況,因爲在我的應用程序,我需要能夠觸發報警按鈕在不同的頁面上按下,在這個例子中看起來像是碰碰運氣。

任何幫助或在正確的方向微調非常感謝!

UPDATE:

這似乎只與iOS 6和6.1模擬器發生。當警報沒有彈出時,按主頁鍵,然後再次打開應用程序會使缺失警報一次顯示。

這個例子也具有相同的行爲:http://docs.phonegap.com/en/2.3.0/cordova_notification_notification.md.html#Notification

任何人都可以證實這只是最新的Xcode模擬器錯誤?

+0

你可以添加<!DOCTYPE html>作爲你的文檔類型嗎? – 2013-02-06 14:31:20

+0

感謝您的建議,這是我的代碼只是沒有公佈上面。編輯我原來的帖子以反映這一點。 – Luke

+0

您的代碼適用於我... – 2013-02-06 14:59:45

回答

1

此問題自Phonegap 2.2還存在: Notification in PhoneGap for iOS Phonegap 2.3上WindowsMo​​bile的相同問題。

我沒有從2.1更新...似乎是它正常工作的最後一個版本。

不要忘了在上面加上document.addEventlistener("deviceready", onDeviceReady, true);

0

更新至最新版本的phonegap(2.4.0)。似乎解決了這個問題。至少對我來說,現在一切正常。

相關問題