Local Notifications Crash App on iOS if App is closed

Hello! I’m using Version 2015.2605 (2015.4.4) of Corona and if I have a local notification sent and the app has been closed the notification fires correctly but when I hit it to open the app the launch screen shows and then the app crashes. If the app is already open then it works fine. I’ve removed everything from my app except only the notification code and the same problem still occurs so I’m thinking it’s either an OS or Corona problem.  Has anyone else experienced anything similar? Thanks!

Hi @hello40,

Can you please read through the guide on notifications and ensure that you didn’t miss a subtle but important step?

http://docs.coronalabs.com/guide/events/appNotification/index.html

Thanks,

Brent

Hi Brent!

 I’ve followed the guide exactly and boiled it down to be as simple as possible but still on iOS if the app is completely closed and the local notification triggers it opens the app to show the loading screen but then crashes.

As a note, it’s not setup to send any launch arguments, just open the app.

Hi @hello40,

Can you post some code related to this?

Thanks,

Brent

Attached is a stripped down version of the app that’s nothing but the notification code.  I’ve set it to send a notification a minute after the app is launched.  Like I said, if the app isn’t running the notification doesn’t work but it works fine otherwise.  Thanks!

Hi again,

Did you follow the example in the documentation? Note the usage of the “launchArgs”, and also note that if you simply want to deliver a notification 60 seconds after the app starts, you probably don’t need to bother with all of the time calculation code… as the documentation says, the time can be a number “indicating the number of seconds from this schedule call until delivery”, so just pass in 60 and that will trigger the notification for 60 seconds in the future.

http://docs.coronalabs.com/plugin/notifications/scheduleNotification.html

Best regards,

Brent

60 seconds was just for the example.  Typically it sends at calculated times of the day, but for testing I wanted to make it easier.  Regardless, it still doesn’t solve the problem of the app not launching from the notification with either time method used. Even with the launch arguments it still has the same response. 

As a reminder, the notifications work perfectly fine and open the application if it’s already running.  It’s only when the app is completely closed and a notification is hit that the app crashes, which leads me to believe it has nothing to do with the time setting.

Hi @hello40,

At this point, I think we’re going to need a bug report filed on this so engineering can inspect it and see what the issue may be. Can you please file one and include the most basic project you have?

http://developer.coronalabs.com/content/bug-submission

Thanks,

Brent

Was this ever fixed? I’m still getting this problem 

Hi @zv713,

I’m not sure if the previous poster ever filed a bug report. Can you do so please?

https://developer.coronalabs.com/content/bug-submission

Thanks,

Brent

I just tested the LocalNotifications sample app that shipped with Corona and I don’t see any app crash when restarting the app after the app is completely closed and a location notification occurs. Can you try the sample to see if you get the same results?

If the sample doesn’t fail you should check what your code is doing differently that may cause it to crash.

Ok I dissected the problem. The options table for the scheduleNotification table needed all 4 variables (alert, badge, sound and custom), even though the docs have each of them as optional. This was a bit misleading, but it’s working correctly now.

Hi @hello40,

Can you please read through the guide on notifications and ensure that you didn’t miss a subtle but important step?

http://docs.coronalabs.com/guide/events/appNotification/index.html

Thanks,

Brent

Hi Brent!

 I’ve followed the guide exactly and boiled it down to be as simple as possible but still on iOS if the app is completely closed and the local notification triggers it opens the app to show the loading screen but then crashes.

As a note, it’s not setup to send any launch arguments, just open the app.

Hi @hello40,

Can you post some code related to this?

Thanks,

Brent

Attached is a stripped down version of the app that’s nothing but the notification code.  I’ve set it to send a notification a minute after the app is launched.  Like I said, if the app isn’t running the notification doesn’t work but it works fine otherwise.  Thanks!

Hi again,

Did you follow the example in the documentation? Note the usage of the “launchArgs”, and also note that if you simply want to deliver a notification 60 seconds after the app starts, you probably don’t need to bother with all of the time calculation code… as the documentation says, the time can be a number “indicating the number of seconds from this schedule call until delivery”, so just pass in 60 and that will trigger the notification for 60 seconds in the future.

http://docs.coronalabs.com/plugin/notifications/scheduleNotification.html

Best regards,

Brent