2013-12-12 13 views
5

私はローカル通知システムでアプリケーションを実装しようとしています。システムは不要な通知を取り消す必要があります。 System.scheduleNotificationは正常に動作し(通知を作成して正常に動作しますが)、nil(IDを返すと想定されます)を返します。通知IDで通知をキャンセルすることはできません。Corona、system.schedule通知が正しく機能していません

実際に使用するコードは非常に簡単です。すべてのヘルプは...

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役立つだろう:私はまたutcTime引数でsystem.scheduleNotificationを試してみました。

答えて

2

あなたのコードのすべてを投稿していないので、あなたのコードが何をしているのか分かりません。オプションでアラートが文字列であることを確認してください。

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

システム通知で通知テーブルに1が追加されていることに注意してください。今すぐsystem.scheduleNotificationstringではありません。それはテーブルなので、print(notifications[#notification])にしようとするとnilが印刷されることになります。私はあなたがnotification[alert]を印刷しなければならないと思いますが、わかりません。このリンクを確認してください:http://lua-users.org/wiki/TablesTutorial

3

corona simulatorのアプリを作成していますか?その後、それは動作しません。地元の通知をテストするためにXcode simulatorのためにそれを構築してください。出力画像(corona Sample Codeから)サンプルプロジェクトを以下に示す:

enter image description here

、コードは次のとおり

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 

コーディングキープ.............. :)

+0

私はデバイスとxcodeシミュレータを試しました。この例を試してみましょう。私はそれがコロナサイトにあると仮定します。返信ありがとう。 –