2014-03-26 43 views
0

我使用phonegap Navigator.notification.alert在我的iPhone應用程序中顯示警報。
但是,當我調用Navigator.notification.alert時,屏幕上沒有顯示任何內容。
然後當我嘗試離開應用程序時(雙擊主頁按鈕),或者我離開應用程序,然後再打開它。
彈出警報。
所以我的功能Navigator.notification.alert工作,但東西停滯在彈出屏幕上的警報。
而不只是警報,Navigator.notification.confirm功能也不能彈出。
這會導致什麼?
感謝您的回覆。
Phonegap(3.3.0)Navigator.notification.alert無法在真實設備上彈出(iPhone5s iOS7)

回答

0

我測試了,它是按預期工作,

請確保你安裝了通知插件,

$cordova plugin add org.apache.cordova.dialogs 

,並檢查你的XML,

<feature name="Notification"> 
    <param name="ios-package" value="CDVNotification" /> 
</feature> 

如果仍然存在將其用作如下所述的事件,

document.addEventListener("deviceready", showAlert, false); 

    function showAlert() { 
     navigator.notification.alert(
      'Test Alert on Device Ready!', 
      alertDismissed, 
      'Testing', 
      'Ok'   
     ); 
    } 
     function alertDismissed() { 
      // do something 
     } 

欲瞭解更多信息click here。希望這可以幫助。

+1

謝謝你V_J_S,我檢查了我的插件配置,我正在使用函數就像你寫的那樣。但我沒有「document.addEventListener(」deviceready「,showAlert,false)這行';並再次測試。 – Godspeed

+0

嗨,@ V_J_S。我測試它,但警報不會彈出。我調試這個使用Xcode,我發現進程進入navigator.notification.alert,但不進入CDVnotification.Then當我離開應用程序(單擊主頁按鈕)過程進入CDVnotification。所以這個過程停滯在javascript調用和CDVNotification.m之間。我發現這不僅僅發生在iOS7的iOS7上。 – Godspeed

+0

只需嘗試在簡單的Hello World應用程序中創建警報,然後在ios7中對其進行測試,並讓我知道此通知是否無法顯示。謝謝 – Vinith