Notification plugin not working

I did review that many times. I don’t think any of them apply to what I’m doing.

Hi @dmglakewood,

Please see this thread: the user reports that all 4 keys defined inside the “options” table are working, despite the documentation saying they’re optional. Can you test this and report back so that I may confirm and correct the documentation?

https://forums.coronalabs.com/topic/56066-local-notifications-crash-app-on-ios-if-app-is-closed/#entry296368

Thanks,

Brent

I was hoping that would work but I tried this 

local options = { alert = "Your bonus is ready, click here to claim!", badge = 1, sound = "alarm.caf", custom = { foo = "bar" } } local notification1 = notifications.scheduleNotification(60, options)

still getting the same error logcat is showing this 

06-08 22:22:47.682: I/Corona(10341): stack traceback: 06-08 22:22:47.682: I/Corona(10341): [C]: in function 'scheduleNotification' 06-08 22:22:47.682: I/Corona(10341): ?: in function 'func' 06-08 22:22:47.682: I/Corona(10341): /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:241: in function \</Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:221\>

Do you have the actual sound “alarm.caf”? That is actually for iOS only (not supported on Android) so try a sound file/format that is supported on Android. See this guide:

https://docs.coronalabs.com/guide/media/audioSystem/index.html

Please report back if that changes anything.

Take care,

Brent

That makes sense…I added a woosh.mp3 and changed my code to reflect that and I’m still getting the same error. 

Hi @dmglakewood,

Can you please test out the sample project in your local CoronaSDK folder and see if you have the same problems?

CoronaSDK > SampleCode > System > LocalNotifications

Thanks,

Brent

Hey Brent it works just fine as is in the sample…but if I take the same code that is in the startWTimePress() and put it inside the applicationExit or applicationSuspend functions then suspend the app using the home button or the back button on the device then it errors out. 

Using that sample I just replaced the onSystemEvent with this 

-- Code to show Alert Box if applicationOpen event occurs -- (This shouldn't happen, but the code is here to prove the fact) function onSystemEvent( event ) print (event.name .. ", " .. event.type) if "applicationOpen" == event.type then native.showAlert( "Open via custom url", event.url, { "OK" } ) elseif(event.type == "applicationSuspend" or event.type == "applicationExit") then -- Add badge paramter if not "none" if badge ~= "none" then options.badge = badge end options.custom.msg = "Time Notification" notificationID = notifications.scheduleNotification( time, options ) end end

Hi @dmglakewood,

I’m not sure you should be doing this, i.e. scheduling a notification on application termination. What is your reason for attempting this? How does it work within the design or your app?

Brent

It works just fine with the depreciated version of notifications. In my app I have a bonus that shows every 3 hours. If the user is in the app they will get it, however if they hide or exit the app the notification will show when the bonus is ready for the user.

Hi @dmglakewood,

I asked the engineers for more information on this. They report that Android does not actually require the “notification” plugin. The system.scheduleNotfication() function still exists and will work on Android, but it’ll just log a “deprecated” message when used. Can you try just using it outright (no plugin) and see what happens?

Thanks,

Brent

Yes this works and it’s how I used to do it before seeing the deprecated messages and decided while I was in the codebase to go ahead and update it to the new method. 

Bump any word on this? Is it a bug that the notifications can’t be called on app hide or close or is it done on purpose?