I'm currently making a TODO app and I save the date that the user has to do a thing. Let's say that he saves the date 28-7-2016 to do something, I make another column tobenotified and I take the date minus it by 1 and save it, so the user should be notified the previous day that tomorrow has a thing to do.
But what if the user has closed the app(killed it). What is the proper way to send a notification from the Realm database when the date tobenotified is equal with NSDate() / the current date?
It's not as simple like that. Realm queries can neither match against a live-updating current date nor send notifications from the background.
You want to look into UILocalNotification and set it up with the tobenotified date as fireDate and schedule it locally. Note that you will require your users consent and have asked them initially by registering for local notification types so that you're permitted by the OS to schedule and present notifications. Also if the user can modify or delete a reminder, then you need to find a way to identify the notification via the the provided identifier and remove or re-schedule it accordingly.
Related
I'm trying to implement local notifications to my app. They will function as a reminder for an event, but the notifications must come from my app, and not from Calendar or Reminders.
My question is, how can I create notificaitons that fire before a certain date, while showing the actual date in the 'time-field'?
This is what the Calendar can do:
Notice the top right corner saying "in 5m".
I'm trying to get the same functionality for my own notifications, but I can't find anything about it. This is the only thing I can get:
As soon as the notification arrives, it says "Now", and then proceeds to count up the amount of minutes ago. I need it to be sent X minutes before, and count down to "Now", then count up. Is this possible?
How about you create multiple custom Notification.Name like this posting. You could have .onTime, .fiveMinutesReminder, .tenMinutesReminder, and so on. The logic in your app would set when to fire those reminders. Your selector handler function would need to have some kind of switch statement to handler different reminder. The handler will need to show different text message based on the kind of the reminder.
I've been working on a new app that leverages the use of location based reminders via geofencing.
As far as I understand, in order to do that, the app must request authorisation via:
CLLocationManager.requestAlwaysAuthorization()
So far, it works as expected, but I'm curious how for example the "Reminders" app, and others such as Omnifocus only request for "When in use" or:
locationManager.requestWhenInUseAuthorization()
Those apps are still able to provide location based reminders without requesting always authorisation. I also noticed that these apps won't trigger the "location" icon on the status bar while in background, which my app does. How do they get these apps to deliver those notifications then?
Thanks!
D
Found the answer while watching the WWDC CLLocation updates to iOS 8 available here:
https://developer.apple.com/videos/wwdc/2014/?id=706
Reminders and similar apps work without requiring for AlwaysAuthorization since they take advantage of the UILocalnotification framework changes. Since iOS 8, it supports Region Based Triggering.
So now if you do not need to actually "Launch" your app in the background and do something when location changes, and just present a notification, you can just use UILocalNotification and RegionBased Triggering.
#NSCopying var region: CLRegion!
in iOS8, UILocalnotification has the 'region' property, which correspondes to a CLRegion object.
From Apple docs:
Assigning a value to this (region) property causes the local notification to be delivered when the user crosses the region’s boundary. The region object itself defines whether the notification is triggered when the user enters or exits the region. The default value of this property is nil.
You may specify a value for this property or the fireDate property but not both. Attempting to schedule a local notification that contains both a region and fire date raises an exception.
so I'm using OCPrayerTimes to get a set of strings in an
I use this code to get the array,
NSMutableArray *prayerTimes = [prayerTime prayerTimesDate:[NSDate date]
latitude:3.1667
longitude:101.7000
andTimezone:[prayerTime getTimeZone]];
I then set notifications for each date in that array. Now my problem is that everyday those dates change so the user would have to re-open the app at midnight to get the new dates so the notifications would work.
Would I have to somehow run the viewdidload method at midnight everyday?
Thanks.
You can't automatically run your app every day, but you can schedule up to 64 local notifications, so you could calculate the prayer times for the next 12 days, and schedule notifications for all of them. This way the app wouldn't have to be opened every day.
What I'd like to do is to set-up a local notification in my iOS app which can remind me one hour ahead of a meeting, and gives me the distance between my current location and the location of the meeting. This means I need to update the alert message when the notification is fired. Is it possible to do it in iOS?
I found this related question how can i set alertbody text on runningtime when local notification is fired in ios4 develop?, but it's more than 2 years old. So I'm hoping there is at least some work-around to have such functionality.
According to the documentation :
The alert has a property for the message (the alertBody property) and for the title of the action button or slider (alertAction); both of these string values can be internationalized for the user’s current language preference.
Check here for some example
I'm trying to make an app that warns me when a current event is going to end. I have an entity (the event), with a date attribute - which is the end date for the event. How can I set a notification alert to pop up for like two days before the event ends? Any links to other tutorials or any hints will be much appreciated.
You can use Local Notifications for this.
http://developer.apple.com/library/ios/#DOCUMENTATION/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008194