这是我在index.js中的代码:
$.ajax({
type: 'GET',
data: {registrationdata: registrationDataJson},
async: false,
url: 'https://example.com/push_reg',
success: function(data){
alert("Your device has been successfully registered for push notifications with device id of: " + data);
},
error: function(){
alert('There was an error registering your device');
}
});
我已经尝试过async on和async off。我不会从成功或错误中得到任何警报。我在/push_reg
路由的第一个地方放了一个日志行。如果我在桌面浏览器中点击它,它会记录但不会从应用程序中记录。我在此代码块之前有alert(registrationDataJson);
(registrationDataJson
是一个字符串化的JSON)所以我知道数据是好的。我直接在这个代码块后面alert('after');
,我从来没有打过,所以我知道它永远不会超过这个块。
答案 0 :(得分:0)
您可能需要详细说明并指出您看到的错误消息代码/错误。检查配置等设置
答案 1 :(得分:0)
请检查您的config.xml文件并确保您拥有以下内容:
<plugin name="cordova-plugin-whitelist" source="npm" spec="1.1.0" />
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />
<preference name="permissions" value="none"/>