一旦有人向我指出这一点,我就会觉得自己像个十足的白痴,但我遇到了语法错误,我无法弄清楚问题出在哪里。这是我的代码(错误出现在最后一行,但我怀疑是该行导致的):
// handle GCM notifications for Android
function onNotificationGCM(e) {
switch( e.event )
{
case 'registered':
if ( e.regid.length > 0 )
{
// Your GCM push server needs to know the regID before it can push to this device
// here is where you might want to send it the regID for later use.
PushWoosh.appCode = "33F93-5013B";
PushWoosh.register(e.regid, function(data) {
alert("PushWoosh register success: " + JSON.stringify(data));
}, function(errorregistration) {
alert("Couldn't register with PushWoosh" + errorregistration);
});
}
break;
谢谢大家,我感觉自己像个白痴,度过了令人沮丧的一天。
最佳答案
您的 onNotificationGCM()
函数未关闭,并且其中包含的 switch block 也未关闭。 JavaScript 解析器期望看到两个额外的右大括号 (}
),但输入文件在看到它们之前就终止了。
我的猜测是,您需要在 break;
语句之后、在分配 PushNotification.prototype.register
之前添加这两个大括号。
关于javascript - 我找不到这个语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16286983/