Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Corona, system.scheduleNotification not working properly

I'm trying to implement an app with a local notification system. The system should cancel some unnecessary notifications. System.scheduleNotification works fine (it creates notifications and they work fine) but it returns nil (It supposed to return an ID). So I'm not able to cancel any notifications by notification id.

Actually the code I use is very simple. Any help would be helpful...

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: I also tried system.scheduleNotification with utcTime argument.

like image 905
Doğancan Arabacı Avatar asked Dec 12 '13 14:12

Doğancan Arabacı


People also ask

What are exposure notifications iPhone battery?

The exposure notification feature is designed to automatically send you a notification if you've been in proximity to a person who is diagnosed with COVID-19. But if you're concerned that you've missed a notification or should have had one, you can manually check for them on your iPhone by following these steps.

How do I schedule a notification in Expo?

You can configure expo-notifications using its built-in config plugin if you use config plugins in your project (EAS Build or expo run:[android|ios] ). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect.


1 Answers

Are you building the app for corona simulator? Then it won't work. Build it for Xcode simulator for testing local notifications. A sample project(from corona Sample Code) output image is shown below:

enter image description here

And the code is:

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

Keep Coding.............. :)

like image 193
Krishna Raj Salim Avatar answered Sep 29 '22 06:09

Krishna Raj Salim