ios local notification with alertbody depending on current location? - ios

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

Related

Can I create reminder/alert-type notifications from my own app?

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.

Notification from the background

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.

iOS Location Reminders "While Using" the app

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.

iOS app - push notification alert when entity date property reaches deadline

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

Set default iOS local notification style for application

Starting with iOS 5, there are two notification styles: banner and alert (the "old" style). A user can set which style to use for each application in the settings. However, the default now seems to be that notifications are displayed banner style.
I'm using local notifications for reminders about events that will happen "now". A banner disappears shortly after it appeared (and it's not obvious enough that one can tap it), so for these notifications it would be desirable to have the alert style notifications as those stay on screen until the user decided on an action (ignore or go to app).
Is there a way either through code or for example Info.plist entries to tell iOS that the alert style notifications should be used by default (as long as the user hasn't configured something else)?
Update: The absence of information/documentation is not enough for me to have this settled. I want either something like a forum/blog post from someone with authority (Apple employee or someone along the lines of Erica Sadun) saying it's not possible, or if it is possible then I want the solution. A workaround like "ask the user to change the setting" isn't good enough either.
I would like to add something, since I've opened a TSI and somehow I asked about this and have been answered. From Quinn "The Eskimo!":
"This depends on you mean. You have some control over how the notification appears based on how you set the UILocalNotification properties (things like alertBody, soundName, and so on). However, if you're asking about the way in which those properties are interpreted (the things the user can customise in Settings > Notifications), those are user preferences and not exposed via any API."
I have an alarm app for which I also need this functionality. Under iOS5 if the user is using another app when it goes off then the banner appears. Consequently I spent a lot of time browsing for a solution.
However, it's not possible to control the style of alert generated by a UILocalNotification I'm afraid :(
You can see from the class reference that there's no provision for it:
http://developer.apple.com/library/IOs/#documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html
Or in the plist:
http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html
Best thing to do is tell the user what to do to change the settings.
You probably won't find 'authoritative' from your peers here, you should better ask directly to Apple; and the question has already been asked several times on theirs forums and not answered...
The HIG programming guide - http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/TechnologyUsage/TechnologyUsage.html#//apple_ref/doc/uid/TP40006556-CH18-SW1 -
"iOS apps that support local or push notifications can participate in
Notification Center in various ways, depending on the user’s
preferences."
That last sentence is the only 'authoritative hint' i found.
The USER'S preferences <= you can't force the user ('s preferences).
Period.
This design choice is clearly the Apple Way (applications' playground IS limited, to ensure the best user experience possible)
As for more authority... maybe shouting ?
NO YOU CAN'T CHOOSE YOUR NOTIFICATIONS DISPLAY STYLE, IT'S THE USER'S CHOICE
Just kidding...
Anyway, a workaround might be to provide a way in your application - hint/ tutorial - to push the user to change the alert style himself...
good luck !
Obviously you don't like hearing no for an answer, but, no.
You can use this line to query the current settings for notification style:
UIRemoteNotificationType* enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
You can check the enabledTypes and then instruct the user to change the notification style in the settings.
have you tried
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
in your didFinishLaunching method, this won't help those updating but should enable alerts for those first installing

Resources