因此,我使用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中的一個相當老的項目) –