2013-07-09 85 views
1

我一直花費一些時間試圖找出爲什麼我無法在自己的應用上使用自定義通知來工作。JQuery + PhoneGap - 自定義通知提醒

下面是我的.js代碼:

if (inputOne > maxAllowed) 
{ 
    showMessage("Your Input is too high.",null,"Warning","Warning"); 
} 

下面是我的.html代碼:

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

function onDeviceReady() { 
     // Now safe to use the PhoneGap API 
} 

function showMessage(message, callback, title, buttonName) { 

    title = title || "Warning!"; 
    buttonName = buttonName || 'Warning!'; 

    if(navigator.notification && navigator.notification.alert) { 

      navigator.notification.alert(
       message, // message 
       callback, // callback 
       title,  // title 
       buttonName // buttonName 
      ); 

    } else { 
      alert(message); 
    } 

在我的config.xml爲PhoneGap的,我有:

下面是我用來得到它的鏈接:

http://docs.phonegap.com/en/2.9.0/cordova_notification_notification.md.html#Notification

會發生什麼,它只是使用else部分,並正常工作。

的html的是從下面的鏈接:

Custom JavaScript alerts in iOS using PhoneGap HTML

任何想法嗎?

謝謝,任何幫助表示讚賞。

親切的問候,

加里Shergill

+0

位於代碼中的頂部代碼段位於相對於底部代碼段的位置? –

+0

他們在兩個不同的文件。該showMessage是在我的JavaScript文件(computations.js)以及應用程序後面的所有數學。 function()部分位於腳本標記<>中的index.html中。 – Gary

回答

-1

對於任何人看到這個問題,你需要添加下面的index.html的:

<!-- Add PhoneGap library --> 
<script type="text/javascript" src="phonegap.js"></script> 

祝你好運!