谁能帮助我,我将不胜感激 我需要检索每个设备和服务器 phonegap 的 regid 并为我服务,但是当我在 android 设备上模拟时,不再显示 id
index.js
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
document.getElementById("toggleBtn").addEventListener('click', this.toggle, false);
},
onDeviceReady: function() {
console.log('deviceready event');
app.push = PushNotification.init({
"android": {
"senderID": "143828535864"
},
"ios": {},
"windows": {}
});
app.push.on('registration', function(data) {
console.log("registration event: " + data.registrationId);
document.getElementById("regId").innerHTML = data.registrationId;
alert(data.registrationId);
var oldRegId = localStorage.getItem('registrationId');
var idReg=jQuery("#idReg").val(data.registrationId);
if (oldRegId !== data.registrationId) {
// Save new registration ID
localStorage.setItem('registrationId', data.registrationId);
}
});
},
};
app.initialize();
和 config.xml
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-navigation href="*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<allow-intent href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<!--<plugin name="PushPlugin" value="com.plugin.gcm.PushPlugin" />-->
<plugin name="phonegap-plugin-push" spec="~1.7.2" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-device" spec="0.2.3" />
最佳答案
首先检查 Google 开发人员控制台项目中的发件人 ID 并尝试进行以下更改。
app.push = PushNotification.init({
"android": {
"senderID": "143828535864"
}
});
关于javascript - PhoneGap 推送插件注册 ID 在移动设备上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38427316/