我熟悉Parse Push通知,但在规划应用程序时,我有一个想法,一旦用户在某个位置(公园,博物馆等)发送推送通知
这可能吗?
答案 0 :(得分:0)
这可以轻松完成,无需解析。在您的app delegate
中添加此代码
// START WITH
[self.locationManager startUpdatingLocation];
pragma mark - CLLocationManagerDelegate
/*
* locationManager:didUpdateToLocation:fromLocation:
*
*/
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
if (UIApplication.sharedApplication.applicationState == UIApplicationStateActive)
{
// ACTIVE APP, pin in a map
}
else
{
NSLog(@"App is backgrounded. New location is %@", newLocation);
// LOCAL PUSH IF NEAR.
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = @"You are near";
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}
}
请务必添加 info.plist
"应用程序注册位置更新"