Android 如何在pushwoosh中作为首选项管理注册?
我遵循了,但发现它只是一遍又一遍地注册你的应用程序以获取通知,用户无法选择退出。似乎没有办法判断设备是否已注册,因为该插件的Android版本中没有Android 如何在pushwoosh中作为首选项管理注册?,android,push-notification,cordova,google-cloud-messaging,Android,Push Notification,Cordova,Google Cloud Messaging,我遵循了,但发现它只是一遍又一遍地注册你的应用程序以获取通知,用户无法选择退出。似乎没有办法判断设备是否已注册,因为该插件的Android版本中没有getRemoteNotificationStatus方法。我怎样才能得到这个信息 我想我应该把它作为首选项保存在应用程序中,这样我就不必查询任何外部信息,但更新版本的Android允许你在应用程序之外禁用通知。此取消注册/与我单独的应用程序内首选项冲突吗 到目前为止,我的代码(我正在使用它进行测试): $document不是打字错误,它已经定义好了
getRemoteNotificationStatus
方法。我怎样才能得到这个信息
我想我应该把它作为首选项保存在应用程序中,这样我就不必查询任何外部信息,但更新版本的Android允许你在应用程序之外禁用通知。此取消注册/与我单独的应用程序内首选项冲突吗
到目前为止,我的代码(我正在使用它进行测试):
$document
不是打字错误,它已经定义好了app.pushPref
是首选项获取功能window.plugins.pushNotification.ondevicerady
已在devicerady
上的其他位置完成appready
是一个合成事件,我在deviceready
和本地数据存储库触发的另一个事件之后触发该事件。您做的事情是正确的
不幸的是,这是唯一的选择,因为Android没有为您提供API来获取推送通知的启用/禁用状态。而这些设置被深深地埋藏在选项中,我真的怀疑用户是否能找到它
无论如何,在本地保留注册信息是目前唯一的选择
(function() {
var pushPrefApply = function() {
app.pushPref(function(pushPref) {
console.log('pushPref', pushPref);
if (!pushPref) {
window.plugins.pushNotification.unregisterDevice(
function() {
console.log('unreg ok', arguments);
},
function() {
console.log('unreg fail', arguments);
}
);
return;
}
window.plugins.pushNotification.registerDevice(
{
projectid: '123456789012',
appid : 'F0000-BAAAA'
},
function(pushToken) {
console.log('reg ok', arguments);
},
function(status) {
console.log('reg fail', arguments);
}
);
});
};
//UI code for changing push preference goes here, calls pushPrefApply
$document.on('appready', function() {
pushPrefApply();
});
})();