问题描述:

I want to notify user from nearby place from location I'll use local notification background and use distanceFromLocation for detect location

I'm using below code :

CLLocation *test = [[CLLocation alloc]initWithLatitude:maylat longitude:mylon];

if([mylo distanceFromLocation:test]<= 50){

NSLog(@"at in 1");

UILocalNotification *notification = [[UILocalNotification alloc] init];

notification.fireDate = [[NSDate date] dateByAddingTimeInterval:0];

notification.soundName = UILocalNotificationDefaultSoundName;

notification.alertBody = @"place1";

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

}

else if([mylo distanceFromLocation:test3]<= 30){

NSLog(@"at in 2");

UILocalNotification *notification = [[UILocalNotification alloc] init];

notification.fireDate = [[NSDate date] dateByAddingTimeInterval:0];

notification.alertBody = @"place2";

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

}

Thanks

相关阅读:
Top