The problem I have is to do with running a function (for an app in the background) when a local notification goes off. The trick is that I am trying to make it so that even if the user does nothing to the notification, the function will still run. Therefore I am trying to figure out a way which when a local notification is triggered, the background mode for an app is opened for a short period of time where I can make changes. I have found that the application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
method could well be what I'm after however this app has be able to run without internet. Therefore, push notifications are out of the question. Is there any methods similar to this which will work offline (local notifications) or is this method not what I'm after? Any sort of help with the topic will be very much appreciated.
Asked
Active
Viewed 271 times
0
-
Local Notifications don't need a network connection, but you have to set a trigger date/time for them. – Pierce Jan 28 '17 at 03:56
-
Ok I see however, how can I then run a function when the local notification goes off? – imjonu Jan 28 '17 at 04:11
-
you can add an action to the local notification.. that action will be called only if the user clicks the button under the notification – Ganesh Kumar Jan 28 '17 at 04:36
-
There is no way of executing code at a specific time when your app is in the background. – Paulw11 Jan 28 '17 at 04:40
-
Sorry, I'm not sure if my question wasn't clear however, I am trying to call the function even if the user does not interact (click) the notification. – imjonu Jan 28 '17 at 05:51
-
@imjonu - That can't be done. That's specifically why Apple has these protocols. They don't want people making apps that perform actions in the background without peoples knowledge. I realize your intentions probably aren't sinister but imagine the bad things people could do. – Pierce Jan 28 '17 at 17:07
-
Yeah after reading a little more thats what I've found. Would the app still get rejected however if I explain to apple why I have done this? In this particular case it is an app for aviation safety or would it be a straight no? – imjonu Jan 29 '17 at 10:19