Daniel
Daniel

Reputation: 458

iOS showing a notification dependent on both location and time

I'm making an iPhone application that needs to show a notification to the user depending on their location as well as the date. The date will be within a date range specified by a server (downloaded when the user first opens the app), and the location is a location within an area; any location within the described area will return true, and if the user is in the area and it is in the specified date range, the phone will display a notification.

I know I can execute code once the user opens the application to check both these conditions, but I don't want that. I want it to display a notification ONLY if these 2 conditions have been fulfilled, which the user can then click to enter the application. Is this even possible?

I looked at push notifications as well, and it doesn't look like I will be able to do that.

Upvotes: 1

Views: 738

Answers (1)

sch
sch

Reputation: 27536

You can use Core Location to monitor the location of the device by calling the startMonitoringForRegion:desiredAccuracy: method of your CLLocationManager.

When the user enters the specied region, your app is notified and locationManager:didEnterRegion: is called. You can check the date in that method and if it is in the specified date range, you can display the notification.

Have a look here and particularly here form more details.

Upvotes: 4

Related Questions