【发布时间】:2025-11-27 11:55:02
【问题描述】:
所以我使用 arrowdb 和带有 Appcelerator 的云服务发送推送通知。这似乎运作良好,iPhone 收到通知。我想知道是否有一些简单的方法可以将徽章编号清除为 0?我猜它也需要在arrowdb服务器(或苹果)上重置。
我希望每次打开应用时都重置徽章。
我所做的是在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 设备上...我应该这样做吗?
【问题讨论】:
标签: titanium push appcelerator arrowdb