且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用位置 IOS 解析推送通知

更新时间:2023-02-26 21:13:39

这可以轻松完成,无需解析.将此代码添加到您的应用委托中

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

应用注册位置更新"