LocalNotification不是基于地区的火灾

时间:2017-05-15 06:15:49

标签: ios objective-c core-location uilocalnotification geofencing

您好我正在尝试制作闹钟应用,但这将适用于基于地区的用户。用户选择该地点,如果用户到达该地点,则会触发本地通知。

-(void)openLocationSearchControl{

    double userLatitude = [lat doubleValue];
    double userLongtitude = [lon doubleValue];

    CLLocationCoordinate2D center = CLLocationCoordinate2DMake(userLatitude, userLongtitude);
    CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(center.latitude + 0.001, center.longitude + 0.001);
    CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(center.latitude - 0.001, center.longitude - 0.001);
    GMSCoordinateBounds *viewport = [[GMSCoordinateBounds alloc] initWithCoordinate:northEast
                                                                         coordinate:southWest];
    GMSPlacePickerConfig *config = [[GMSPlacePickerConfig alloc] initWithViewport:viewport];
    _placePicker = [[GMSPlacePicker alloc] initWithConfig:config];



    [_placePicker pickPlaceWithCallback:^(GMSPlace *place, NSError *error) {
        if (error != nil) {
            NSLog(@"Pick Place error %@", [error localizedDescription]);
            return;
        }

        if (place != nil) {
            NSLog(@"Place name %@", place.name);

            NSLog(@"Place address %@", place.formattedAddress);
            NSLog(@"Place attributions %@", place.attributions.string);
            self.notifLocation = [[CLLocation alloc] initWithLatitude:place.coordinate.latitude longitude:place.coordinate.longitude];

            UILocalNotification *notification = [[UILocalNotification alloc] init];
            notification.alertBody = place.name;
            notification.soundName = UILocalNotificationDefaultSoundName;
            notification.applicationIconBadgeNumber = 4;
            notification.regionTriggersOnce = NO;
            notification.region = [[CLCircularRegion alloc] initWithCenter:self.notifLocation.coordinate radius:100 identifier:@"PlaceName"];

            [[UIApplication sharedApplication] scheduleLocalNotification:notification];

            if (place.formattedAddress == NULL ) {



            }else{


            }


        } else {
            NSLog(@"No place selected");
        }
    }];

}

现在我正在尝试安排本地通知,但我没有收到任何通知。让我知道我做错了什么。感谢

0 个答案:

没有答案