I have problem with even inventing the posible solution for this problem.
My app needs to crate some objects of UILocalNotification with interval but if I set interval to be NSMinuteCalendarUnit if will bother me every minute until I cancel this notification in UIApplication or crash my phone with hammer...
But I'm setting in my app an end date for my project and I want those notification to work only to a specified date. Someone told me to check it when the app launches (not a problem but what if I set this notification to be fired every minute and I won't close my app during this time?). I need something independent and I want to know how to do this.. Any ideas?
You could check if you need to cancel the local notification in receiving one when you app is running and on the start up of you app.
When your app is running in the foreground and a local notification is fired for you app the application:didReceiveLocalNotification: is called on your App delegate.
There is not end date for local notifications thus the only way you can cancel then is from you app when it is running.
Related
How to do server call even when the app is killed and show localnotification in ios. Right now am running timer in didUpdateLocations. It works fine when app is in background,but not when app is killed.
Please let me know is it possible to do and if yes how?
This not possible using the UILocalNotification. Please refer the Apple document For UILoccalNotification.
Lets get some understanding about the UILoccalNotification.
No method call when the you have received Local Notification.
didReceiveLocalNotification method call when user tap the notification in terminate state.
So basically you can not use UILocalnotification for update location in Terminate state. You cannot do anything once your app has been terminated using local notification
I have an App built on Swift, I want this App to start every day at some particular time. Logically its like Calendar notification, which gives notification in that particular window whatever we set.
Does is the same scenario is possible with an App in iOS Swift.
What you can probably do is to create a local notification, but this is not opening your app. A local notification is just a way to show a notification on your iPhone and then, if the user taps, it's opening your app.
See more here: https://www.codebeaulieu.com/49/How-to-add-local-notifications-to-your-app
I am not sure what you want to do, you cannot force your application upon the user without the user's consent. What you can do is schedule a local notification so the user knows when to open your app like jomafer proposed already. Also possible is to wake up the app to do stuff in the background:
https://developer.apple.com/library/prerelease/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
For example a silent push notification that will trigger some code, or a scheduled background download.
NONE OF THESE METHODS ARE 100% RELIABLE THOUGH!
I have a problem scheduling UILocalNotifications.
My case is this: when user selects motivation category there is a dialog screen where he selects how many times in a day, week, month, motivation message should be presented to him. Then he selects time period: a day, week or a month. A motivation category has messages, and every category has different number of messages.
So my question is: how should i schedule those notifications? Main problem i think is that there can be more than one category. Can someone tell me how to do this?
I know that i cant schedule more than 64 notifications, so i cant schedule all notifications when category is selected. And i know i could reschedule notifications in
application:didFinishLaunchingWithOptions:
or
application:didReceiveLocalNotification:
I hope i have been clear about my problem.
First write a function that manages the local notifications
that is it has to check if there are 64 notifications scheduled if not then you may add some notification.(you have to handle DB part well for example setting the flags correctly)
Call the function in application:didFinishLaunchingWithOptions: just in case some notifications are expired or missed
You have to call the function in all the places where local notification is handled.
The user taps a custom action button in an iOS 8 notification.
In this case, iOS calls
application:handleActionWithIdentifier:forLocalNotification:completionHandler:
You also get the local notification object, so that you can retrieve any information you need to handle the action.
The user taps the default button in the alert or taps the app icon.
The system launches the app and the app calls its delegate’s method, passing in the local notification object
application:didFinishLaunchingWithOptions:
The notification is delivered when the app is running in the foreground.
The app calls the UIApplicationDelegate method
application:didReceiveLocalNotification:
Reference1:
Reference2:
I hope this helps.
If it doesn't cover your problem feel free to ask doubts
It works as pool when you utilized all your available notifications then you need to reschedule the free notifications in
application:didReceiveLocalNotification: but every time you are gonna reschedule you can find next notification to user that could be in today, tomorrow. Whenever you are in application:didReceiveLocalNotification: findout when to notify next and schedule.
I am wondering if it's possible to do what the titles says. I have an application that has a refill reminder to refill your prescription drug via local notifications. I have seen that some apps (pill reminder apps mostly) push a notification if you have not taken your pill, or have not answered back to that notification, and was wondering if I can do the same if a user doesn't open/interact with the app after a certain period of time.
I have not began implementation but have thought about this thoroughly. What I am thinking of doing is having some sort of flag when the app is opened that removes that local notification and sets a new one once the app has gone in the background/inactive. The local notification would be set to three months from when the app has gone in the background/inactive. The question then becomes, how do I handle canceling all notifications after this notification has been received, regardless of whether the user opens the app at that notification or not?
If the user opens the app on that notification, I can have a check the method application:didReceiveLocalNotification and then handle the case where that local notification has been set and then use [[UIApplication sharedApplication] cancelAllLocalNotifications]
But if the user does not tap or open the app, how can I check and cancel all local notifications?
Sorry if this is a bit long or worded weirdly (sorry not good with words and explaining things). Let me know if you need more info or better explanation. Thanks in advance!
If I understand your question correctly, you want to know how to keep notifications from repeating when the user does not respond to a notification by opening your app.
You might consider configuring your local notification not to repeat. Instead, you might reschedule notification batches each time the application is launched.
Alternatively, if your application has a server-side component, you can use push notifications on iOS 7+ to wake your app, briefly. There is no equivalent to this behavior using UILocalNotification.
I am trying to schedule push notifications using Parse in iOS. I only have a free account (meaning that I cannot schedule notifications in the web backend), so I came up with a solution for scheduling the notification through Parse:
Within the app, when you press send notification you set the text and a date to send the notification (using the code to just send a standard PFPush code). Then I just use NSDate and every day check the date to see if it matches the date for the scheduled notification. If it does, it sends the notification; thus sending the notification on the scheduled day, if it is not the matching day, nothing happens (no notification is sent, and the app rechecks in another 24hrs). This works, but the app has to be open in the foreground at the time that the notification is scheduled for sending (i.e the date is not checked and notification not sent if the app is in the background). So my actual question is how I can run all of this in the background, so the app can just be in the background on my iPad, and it will still check the date and be able to post the PFPush (push notification).
Any help or code would be much appreciated.
Thanks so much in advance, and let me know if you need more information!
In this case
setMinimumBackgroundFetchInterval means that it is not called in an interval which is smaller than the value you specified. But there's no setMaximumBackgroundFetchInterval. So if iOS decides to call your app just once a day or even just once a week than it won't be called more often regardless your minimumBackgroundFetchInterval. AFAIK iOS decides when to call performFetchWithCompletionHandler measured by the pattern when and how often the users start's the app.
In Xcode 5 Debug mode, you can force a background fetch from the menu: Debug > Simulate Background Fetch.