因此,我使用Appcelerator使用arrowdb和云服务发送推送通知。这似乎工作得很好,iphone获得通知。我想知道的是,如果有一些简单的方法来清除徽章数量为0?它也需要在arrowdb服务器重置(或苹果),我想。清除徽章号码Appcelerator工作室,arrowdb和iOS?
我想在每次打开应用程序时重置徽章。
我所做的就是在alloy.js
Ti.App.addEventListener("resumed", function(e){
添加简历监听器在事件监听我第一次做(本地复位标记):
Cloud.PushNotifications.resetBadge({
device_token: device_token
}, function (e) {
if (e.success) {
Ti.API.info('Badge Reset!');
}
else {
Ti.API.error(e);
}
});
后来我也发通过发送推送给我们自己来推送清除服务器上的徽章:
var push_payload = {
badge:0,
sound:"",
alert:"",
title:"",
message_text:"",
push_type:"clear",
from_user:Alloy.Globals.currentUser.id,
vibrate:false
};
Cloud.PushNotifications.notify({
channel: 'private_message',
payload: push_payload,
to_ids: Alloy.Globals.currentUser.id
}, function (e) {
if (e.success) {
Ti.API.info('Success sending push notification');
} else {
Ti.API.info('Error sending push: '+((e.error && e.message) || JSON.stringify(e)));
}
});
事件侦听器似乎被称为,推送被发送。但不知何故,徽章仍然保留在iphone设备上......我应该以不同的方式做到这一点吗?
看来我们几乎同时在回答,对不起娟,我不是故意给出另一个稍微不同的解决方案! :) –
jajaja,看起来像但没有问题..只要答案可以帮助@Emil –
其实你是正确的!正如在最新的文档中,setAppBadge在Titanium.UI.iOS中,Titanium.UI.iPhone中没有更多(我现在检查过,我一直在使用3.5.2 SDK中的一个相当老的项目) –