2014-01-29 24 views
1

我使用phonegap CLI來檢查默認通知是否工作。我已經添加了通知插件,我得到這個輸出,當我跑:phonegap通知方法仍然使用webview警報

d:\ PhoneGap的\ APPS \ alerttest>科爾多瓦插件LS

[ 'org.apache.cordova.dialogs',「組織.apache.cordova.vibration」]

這是我的JS怎麼樣子:

document.addEventListener('deviceready', function() { 
    if (navigator.notification) { 
     //Im trying to overwrite the default alert & confirm here if navigator.notification is defined 
     window.alert = function (title, message, button, onFinish) { 
      navigator.notification.alert(message, onFinish, title, button); 
     }; 

     window.confirm = function (title, message, buttons, onFinish) { 
      var onDone = function (btnIndex) { 
       switch (btnIndex) { 
        case 0: 
         break; 
        case 1: 
         onFinish(true); 
         break; 
        case 2: 
         onFinish(false); 
         break; 
       } 
      } 
      navigator.notification.confirm(message, onDone, title, buttons); 
     } 
    } 
    else { 
     var $alertBox = $(".alert-box.warning"); 
     $alertBox.html("No notification support :("); 
     $alertBox.show(); 
    } 
}); 

當我使用這些功能,

alert("Alert", "I was clicked.", "Yes, I got it!", null); 
confirm("Confirm", "2 + 2 = 4. Yes or no?", ["Yes", "No"], onDone); 

我得到的東西像這樣:

for alertenter image description here

仍然是web視圖警報。我期待這樣的事情:

enter image description here

我在做什麼錯在這裏?

使用PhoneGap的CLI,版本號:3.1.0-0.2.0

此外,即時通訊使用的是Android傑利貝恩(4.1.2),以檢查此功能

+1

你在創建項目時選擇了哪個主題? –

+1

主題?什麼主題?你能提供一些鏈接來支持你輸入的內容嗎? – krishgopinath

回答

4

是的我明白了!我不得不將清單文件中的android:theme從「@ * android:style/Theme.Black.NoTitleBar」更改爲「@ * android:style/Theme.DeviceDefault」來中提琴!謝謝Divesh Salian給我一個線索!

+1

很高興它幫助你 –

0

確保這是在你的config.xml -

<feature name="Notification"> 
<param name="android-package" value="org.apache.cordova.dialogs.Notification" /> 
</feature> 
+0

是的。我發現它在../www/&../platforms/android/res/xml/config.xml – krishgopinath