I want to set a location based reminder. This is my code:
我想设置一个基于位置的提醒。这是我的代码:
let locattionnotification = UILocalNotification()
locattionnotification.alertBody = textAllert
locattionnotification.regionTriggersOnce = false
locattionnotification.region = CLCircularRegion(circularRegionWithCenter: CLLocationCoordinate2D(latitude:
mylatitude, longitude: mylongitude), radius: 300.0, identifier: "Location1")
UIApplication.sharedApplication().scheduleLocalNotification(locattionnotification)
mylatitude and mylongitude are double values. The problem is, that Xcode is complaining:
mylatitude和mylongitude是双重值。问题是,Xcode抱怨:
init(circularRegionWithCenter:radius:identifier:)' is unavailable: APIs >deprecated as of iOS 7 and earlier are unavailable in Swift
init(circularRegionWithCenter:radius:identifier :)'不可用:从> 7及更早版本中弃用的API>在Swift中不可用
Is there any better way to set the region based reminder? I already did some research, and saw that it is also possible with CLRegion, but couldn't figure out how to set it up with manually set coordinates.
有没有更好的方法来设置基于区域的提醒?我已经做了一些研究,并且看到它也可以用CLRegion,但无法弄清楚如何用手动设置坐标来设置它。
1 个解决方案
#1
2
You can use another CLCircularRegion
constructor:
您可以使用另一个CLCircularRegion构造函数:
locattionnotification.region = CLCircularRegion(center: CLLocationCoordinate2D(latitude:
mylatitude, longitude: mylongitude), radius: 300.0, identifier: "Location1")
#1
2
You can use another CLCircularRegion
constructor:
您可以使用另一个CLCircularRegion构造函数:
locattionnotification.region = CLCircularRegion(center: CLLocationCoordinate2D(latitude:
mylatitude, longitude: mylongitude), radius: 300.0, identifier: "Location1")