2013-12-12 53 views
5

Yerel bir bildirim sistemi ile bir uygulamayı uygulamaya çalışıyorum. Sistem bazı gereksiz bildirimleri iptal etmelidir. System.scheduleNotification düzgün çalışıyor (bildirimler oluşturur ve iyi çalışırlar) ancak nil döndürür (bir ID döndürmesi gerekir). Bu nedenle, bildirimleri bildirim kimliğine göre iptal edemiyorum.Corona, system.scheduleNotification düzgün çalışmıyor

Aslında kullandığım kod çok basit. Herhangi bir yardım

local nextRefreshTime = 60 -- Not always 60, its just an example 
local options = { 
    alert = "Some text here.", 
    badge = (native.getProperty("applicationIconBadgeNumber") or 0) + 1, 
} 

notifications[#notifications+1] = system.scheduleNotification(nextRefreshTime, options) 
print(notifications[#notifications]) -- Prints nil !?! 
-- Another example (test) 
print(system.scheduleNotification(nextRefreshTime, options)) -- Also prints nil !?! 

P.S. ... yararlı olacaktır: Ben de utcTime argümanı ile system.scheduleNotification çalıştı.

cevap

2

Tüm kodunuzu göndermediniz, böylece kodunuzun ne yaptığını bilmiyorum. Seçeneklerde uyarınızın bir dize olduğundan emin olun. Bu gibi görünmelidir:

local options = { 
    alert = "Wake up!", 
    badge = 2, 
} 

kodunuzu sistem notication bildirim tabloya 1 ekliyor söylediğini unutmayın. Şu anda system.scheduleNotification bir string değil, bu bir tablo, bu yüzden print(notifications[#notification]) için çalıştığınızda nil yazdırır anlamında. Bence notification[alert]'u yazdırmak zorunda kalacaksın ama emin değilim. Bu bağlantıya bir göz atın:

3

Uygulamayı corona simulator için mi yapıyorsunuz? O zaman işe yaramaz. Yerel bildirimleri test etmek için Xcode simulator için kurun. Çıktı görüntü (corona Sample Code itibaren) Örnek bir proje aşağıda gösterilmiştir:

enter image description here

Ve kodudur:

local options = { 
    alert = "Wake up!", 
    badge = 1, 
    sound = "alarm.caf", 
    custom = { msg = "bar" } 
} 

notificationID = system.scheduleNotification(time, options) 

local displayText = "Notification using Time: " .. tostring(notificationID) 
print(displayText) -- It will print the user data 

Kodlama tutun ..............

+0

Cihazda ve xcode simülatöründe denedim. Bu örneği deneyeceğim. Corona sitesinde olduğunu sanıyorum. Cevap için teşekkürler. –