使用位置 IOS 解析推送通知 [英] Parse Push Notifications with Location IOS
问题描述
我熟悉 Parse Push 通知,但在规划应用程序时,我有一个想法,一旦用户位于某个位置(公园、博物馆等),就发送推送通知
Im familiar with Parse Push notifications, but while planning an app i had an idea to send a push notification once a user is in a certain location (a park, a museum, etc)
这可能吗??
推荐答案
这可以轻松完成,无需解析.将此代码添加到您的应用委托中
This can be done easy and with out parse. Add this code in your app delegate
//开始于[self.locationManager startUpdatingLocation];
// START WITH [self.locationManager startUpdatingLocation];
/** locationManager:didUpdateToLocation:fromLocation:**/- (void)locationManager:(CLLocationManager *)managerdidUpdateToLocation:(CLLocation *)newLocationfromLocation:(CLLocation *)oldLocation{
/* * 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
应用注册位置更新"
这篇关于使用位置 IOS 解析推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!