lua - 电晕,system.scheduleNotification 无法正常工作

标签 lua system coronasdk uilocalnotification

我正在尝试使用本地通知系统实现一个应用程序。系统应该取消一些不必要的通知。 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 !?!

ps:我也试过system.scheduleNotificationutcTime争论。

最佳答案

您是否正在为 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

继续编码.........:)

关于lua - 电晕,system.scheduleNotification 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20546656/

相关文章:

compiler-errors - Lua 从 5.1 更新 - LUA_GLOBALSINDEX 问题

mysql - 如何从 luaSQL 查询中获取结果?

java - 通过配置文件初始化 "singleton"是否合适?

php - php中的system()函数是如何工作的?

android - Android 上的 Corona SDK 音频调谐器?

ios - 如何在同一个应用中支持IOS6和IOS7的应用图标和启动图像?

oop - Corona SDK 如何向显示对象添加自定义方法

java - LuaJava:从Java调用Lua对象上的方法?

nginx - 带有 nginx 的 lua 脚本中的持久性 redis 句柄

使用 execv 调用 'ls'