加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

lua – Corona,system.scheduleNotification无法正常工作

发布时间:2020-12-14 21:46:56 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用本地通知系统实现应用程序.系统应取消一些不必要的通知. System.scheduleNotification工作正常(它创建通知,它们工作正常),但它返回nil(它应该返回一个ID).所以我无法通过通知ID取消任何通知. 实际上我使用的代码非常简单.任何帮助都会有所帮助
我正在尝试使用本地通知系统实现应用程序.系统应取消一些不必要的通知. 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.

解决方法

你正在为电晕模拟器构建应用程序吗?然后它将无法正常工作.为Xcode模拟器构建它以测试本地通知.示例项目(来自电晕样本代码)输出图像如下所示:

代码是:

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

保持编码…………..

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读