iOS位置提醒应用程序错过某些位置
我们正在构建基于位置的提醒应用程序,它在10个案例中有7个案例有效。它只是错过了某些位置。你能建议一下这可能会有什么问题吗 下面是我们用于位置匹配的逻辑iOS位置提醒应用程序错过某些位置,ios,notifications,geolocation,matching,reminders,Ios,Notifications,Geolocation,Matching,Reminders,我们正在构建基于位置的提醒应用程序,它在10个案例中有7个案例有效。它只是错过了某些位置。你能建议一下这可能会有什么问题吗 下面是我们用于位置匹配的逻辑 -(void)locationChangeLogic { CLLocation *currentLocation = [[CLLocation alloc] initWithLatitude:latitudeTemp longitude:longitudeTemp]; dispatch_async(dispatch_get_
-(void)locationChangeLogic {
CLLocation *currentLocation = [[CLLocation alloc] initWithLatitude:latitudeTemp longitude:longitudeTemp];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Perform long running process
NSArray *arrayLocations = [[NSArray alloc] initWithArray:[[self db] getListOfLocations]];
NSMutableArray *arrayToNotification = [[NSMutableArray alloc] init];
if ([arrayLocations count] > 0) {
for (NSDictionary *dict in arrayLocations) {
CLLocation *newLocation = [[CLLocation alloc] initWithLatitude:[[dict valueForKey:@"latitude"] floatValue] longitude:[[dict valueForKey:@"longitude"] floatValue]];
float miles = [[NSUserDefaults standardUserDefaults] floatForKey:@"miles"];
CLLocationDistance distance = [currentLocation distanceFromLocation:newLocation];
//Set matched objects and update flag
if ((distance/1609.344) <= miles) {
if ([[dict valueForKey:@"isSelected"] integerValue] == 1) {
[arrayToNotification addObject:dict];
}
//Matched location FLAG will going to 0, so notification not get fire twice or repeatedly
}else {
//The location which are not in current redius, we will make those location FLAG to 1, So when user enter in different location it will check for that
}
}
}
dispatch_async(dispatch_get_main_queue(), ^{
if ([arrayToNotification count] > 0) {
[self setAndFireLocalNotifications:arrayToNotification];
}
});
});
}
任何帮助都将不胜感激