admin管理员组文章数量:1025748
Starting to play with phonegap for the android and am not able to get anything in the navigator.notifications
to work (actually looks like navigator.<anything>
is not working). In my JS I have tried
navigator.notification.vibrate(1000);
navigator.notification.vibrate();
navigator.notification.alert("one", "two", "three");
navigator.notification.beep(1);
none of them do anything, the app just continues right on past them like nothing ever happened. If I alert(navigator)
I get [object object]
but alert(navigator.notification)
gives null.
Starting to play with phonegap for the android and am not able to get anything in the navigator.notifications
to work (actually looks like navigator.<anything>
is not working). In my JS I have tried
navigator.notification.vibrate(1000);
navigator.notification.vibrate();
navigator.notification.alert("one", "two", "three");
navigator.notification.beep(1);
none of them do anything, the app just continues right on past them like nothing ever happened. If I alert(navigator)
I get [object object]
but alert(navigator.notification)
gives null.
1 Answer
Reset to default 4PhoneGap for Android supports all three notification methods you mentioned. For me it looks like you try to run them before PhoneGap is ready (so before navigator.notification
object is initialized). Make sure your code is not executed before PhoneGap notify deviceready
event. Just for test you can try to run a code like this:
document.addEventListener("deviceready", function(){
navigator.notification.vibrate(1000);
navigator.notification.alert("Hello");
navigator.notification.beep(1);
}, false);
Please also notice that in your example there is a mistake in alert
method invocation. The second parameter is a callback (executed after user press/taps button on alert), so you shouldn't pass a string there.
Starting to play with phonegap for the android and am not able to get anything in the navigator.notifications
to work (actually looks like navigator.<anything>
is not working). In my JS I have tried
navigator.notification.vibrate(1000);
navigator.notification.vibrate();
navigator.notification.alert("one", "two", "three");
navigator.notification.beep(1);
none of them do anything, the app just continues right on past them like nothing ever happened. If I alert(navigator)
I get [object object]
but alert(navigator.notification)
gives null.
Starting to play with phonegap for the android and am not able to get anything in the navigator.notifications
to work (actually looks like navigator.<anything>
is not working). In my JS I have tried
navigator.notification.vibrate(1000);
navigator.notification.vibrate();
navigator.notification.alert("one", "two", "three");
navigator.notification.beep(1);
none of them do anything, the app just continues right on past them like nothing ever happened. If I alert(navigator)
I get [object object]
but alert(navigator.notification)
gives null.
1 Answer
Reset to default 4PhoneGap for Android supports all three notification methods you mentioned. For me it looks like you try to run them before PhoneGap is ready (so before navigator.notification
object is initialized). Make sure your code is not executed before PhoneGap notify deviceready
event. Just for test you can try to run a code like this:
document.addEventListener("deviceready", function(){
navigator.notification.vibrate(1000);
navigator.notification.alert("Hello");
navigator.notification.beep(1);
}, false);
Please also notice that in your example there is a mistake in alert
method invocation. The second parameter is a callback (executed after user press/taps button on alert), so you shouldn't pass a string there.
本文标签: javascriptPhonegap navigatornotifications does nothingStack Overflow
版权声明:本文标题:javascript - Phonegap navigator.notifications does nothing - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745623701a2159729.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论