Lua Corona,system.scheduleNotification工作不正常

Lua Corona,system.scheduleNotification工作不正常,lua,system,coronasdk,uilocalnotification,Lua,System,Coronasdk,Uilocalnotification,我正在尝试实现一个带有本地通知系统的应用程序。系统应取消一些不必要的通知。System.scheduleNotification工作正常(它创建通知,它们工作正常),但它返回nil(它应该返回一个ID)。因此,我无法通过通知id取消任何通知 实际上,我使用的代码非常简单。任何帮助都会有帮助 local nextRefreshTime = 60 -- Not always 60, its just an example local options = { alert = "Some tex

我正在尝试实现一个带有本地通知系统的应用程序。系统应取消一些不必要的通知。System.scheduleNotification工作正常(它创建通知,它们工作正常),但它返回
nil
(它应该返回一个ID)。因此,我无法通过通知id取消任何通知

实际上,我使用的代码非常简单。任何帮助都会有帮助

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

您没有发布所有代码,所以我不知道您的代码在做什么。确保“选项”中的警报为字符串。它应该是这样的:

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

请记住,您的代码表示您的系统通知正在将1添加到通知表中。现在,
system.scheduleNotification
不是一个
字符串
,它是一个表,因此当您尝试
打印(通知[#通知])
时,它打印
nil
是有意义的。我想您必须打印出
通知[警报]
,但我不确定。查看此链接:
http://lua-users.org/wiki/TablesTutorial

您是否正在为电晕模拟器构建应用程序?那就不行了。为测试本地通知的
Xcode模拟器构建它。示例项目(来自
corona示例代码
)输出图像如下所示:

代码是:

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

继续编码………..)

我试过这个设备,也试过xcode模拟器。我来试试这个例子。我猜它在科罗纳的地盘上。谢谢你的回复。