navigator.notification.alert无法正常工作-PhoneGap [英] navigator.notification.alert not working - phonegap
问题描述
我正在为iphone做一个phonegap项目,我在确认通知回调中有一个phonegap警报。我的确认(navigator.notification.confirm)工作正常,但警报(navigator.notification.alert)无法正常工作,不知道为什么,请在下面粘贴我的代码。
I am doing a phonegap project for iphone, i have a phonegap alert inside a confirmation notification callback. My confirmation (navigator.notification.confirm) works fine but alert(navigator.notification.alert) not working, don't know why is it so, pasted my code below.
function confirmSubmit() {
navigator.notification.confirm(
'Are you ready to submit?', // message
function(buttonIndex) {
onConfirm(buttonIndex);
},
'Confirmation', 'Yes,No' // buttonLabels
);
}
function onConfirm(buttonIndex) {
if (buttonIndex === 1) {
didClickSubmitButton();
} else if (buttonIndex === 2) {
return false;
}
}
function didClickSubmitButton() {
validate();
----some other codes-----
}
function validate() {
navigator.notification.alert("my alert"); // Not working
alert("another alert") //Working
}
<我正在xcode的iPhone模拟器上进行测试,需要您的帮助。谢谢。
I'am testing on iphone simulator of xcode, i need your help. Thanks.
推荐答案
我在android中也遇到了同样的问题。
I faced the same issue in android.
navigator.notification.alert()
不起作用,但 alert()
起作用。为了自定义警报,我希望 navigator.notification.alert()
起作用。
navigator.notification.alert()
was not working but alert()
was working. To customize the alert I wanted navigator.notification.alert()
to work.
因此,我为通知/提示等:
So I added the plugin for notification/prompt etc as:
$cordova plugin add org.apache.cordova.dialogs
然后将以下代码添加到app / config.xml:
then added below code to app/config.xml:
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
因此我得到了navigator.notification.alert()处理标题,消息,回调和按钮名称参数。
Thus I got navigator.notification.alert() working with the title, msg, callback and button name parameters.
这篇关于navigator.notification.alert无法正常工作-PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!