我正在使用Titanium SDK 3.1。我想取消預定的LocalNotification(iOS)。我看到那個方法Ti.App.iOS.cancelLocalNotification(Number id)
(http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.App.iOS),但我不知道如何指定id
當我創建一個Ti.App.iOS.scheduleLocalNotification(<NotificationParams>)
。我讀到我必須在userInfo
屬性內創建一個名爲id
的屬性,但我無法使其工作。使用ID取消iOS預定LocalNotification(Titanium)
示例代碼(不工作):
Ti.App.iOS.scheduleLocalNotification({
alertBody : "My notification",
badge : 0,
repeat : "daily",
userInfo : {
id : 1234
},
sound : "alarm.mp3",
date : new Date()
});
Ti.App.iOS.cancelLocalNotification(1234); // => undefined
我試過的代碼,現在看來工作不錯,但'Ti.App.iOS.cancelLocalNotification(ID)''回報undefined'。這是正常的? – masipcat
@JMasip:cancelLocalNotification()方法返回void。有關更多信息,請參閱http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.App.iOS-method-cancelLocalNotification,如果我的答案解決了您的問題,請將刻度線標記爲 – Anand