如果我选择默认的提醒应用程序在一天(例如 2 月 10 日)提醒我某事,并且在某个位置它会说“在 2 月 10 日,您的基于位置的提醒将处于活动状态”。
所以它甚至可以在特定日期在后台设置基于位置的提醒?
这真的很有趣,我想知道这怎么可能,有什么诀窍还是只是因为 Apple 为他们的股票应用程序提供了无限的权力?
PS - 我已经知道如何设置基于位置的提醒。
如果我选择默认的提醒应用程序在一天(例如 2 月 10 日)提醒我某事,并且在某个位置它会说“在 2 月 10 日,您的基于位置的提醒将处于活动状态”。
所以它甚至可以在特定日期在后台设置基于位置的提醒?
这真的很有趣,我想知道这怎么可能,有什么诀窍还是只是因为 Apple 为他们的股票应用程序提供了无限的权力?
PS - 我已经知道如何设置基于位置的提醒。
Its no big deal. This techniques is called GeoFencing
. You can do it too. Apple Location framework provides some interesting APIs for this purpose.
Try to use the
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region;
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region;
What these delegate methods give you is a easy way to set local notification on a iOS device. So for example you can provide an interface where a user wants to be notified about something when he enters a region
. The definition of region
is nothing but latitude, longitude with a radius defined. Ex. when you enter a certain region on your way to work you can set a reminder to drop off laundry. etc.
It's all actually pretty easy...
To add a little bit more. There are 2 sides to this. First setting the notification, next is consuming or showing the notification. Setting the notification is a straightforward user's current location capture. While doing tell locationManager to monitor this region. When the user enters this region (you could have a date as further filtering criteria) then alert the user.
All this will work even if your app is running in background or closed. iOS will take care of this.