Notifications 使用Corona的Android本地通知

Notifications 使用Corona的Android本地通知,notifications,coronasdk,Notifications,Coronasdk,我正在尝试创建3个通知,间隔10秒。但是,它只播放第一个声音,并以10秒的间隔永远重复。你能检查一下我的代码并告诉我我做错了什么吗 local futureTime = 10 --10 seconds local sounds = {"Icebaby.mp3", "Pokemon.mp3", "Yoshi.mp3"} i=1 local options = { alert = "Wake up!", sound = "Icebaby.mp3" , custom = { msg =

我正在尝试创建3个通知,间隔10秒。但是,它只播放第一个声音,并以10秒的间隔永远重复。你能检查一下我的代码并告诉我我做错了什么吗

local futureTime = 10  --10 seconds 
local sounds =  {"Icebaby.mp3", "Pokemon.mp3", "Yoshi.mp3"}
i=1

local options = {
 alert = "Wake up!",
 sound = "Icebaby.mp3" ,
 custom = { msg = "Alarm" }
}

local notificationID = system.scheduleNotification( futureTime, options )

local function notificationListener( event )

system.cancelNotification(notificationID)
i=i+1
options.sound=sounds[i]
    if(i>3) then
    Runtime:removeEventListener ( "notification", notificationListener )

    else 
        notificationID = system.scheduleNotification( futureTime, options )
    end
end


Runtime:addEventListener( "notification", notificationListener )

第一个问题:它只播放第一个声音 ->是的,因为您不更改选项表。所以它总是这个选项表:

local options = {
 alert = "Wake up!",
 sound = "Icebaby.mp3" ,
 custom = { msg = "Alarm" }
}

每次创建下一个通知时更改选项表。例如,使用您的声音表

我确实在notificationListener函数中更改了它:options.sound=sounds[I]您可以这样做,但您不会在任何地方使用sounds[I]。同样,在notificationListener的else条件中,在更新选项表中的sound之后,我正在使用options参数创建另一个通知。我漏掉什么了吗?对不起,漏掉了那部分你试着打印出我的价值吗?所以你可以看看它是否出了问题。正如我所看到的,它是一个全球性的,可以从外部人工操作。我把它制作成本地的,并进行了测试,但现在它只播放表中最后的声音。你在你的设备上测试过代码吗?我现在不能在设备上测试,但是你能使用一些打印功能来跟踪代码吗?你们应该在if-else blockWell中使用它们,通知在模拟器中不起作用,在这种情况下打印是无用的。