0

アプリケーションの 1 つにジオフェンシングを使用しています。しかし、私はそれで1つの問題を抱えていました。アプリケーションがバックグラウンドモードの場合、(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)regionが呼び出されません。

設定でアプリのバックグラウンド更新フラグがオンになっていることを確認します。

以下は私のコードです:

- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
    if (state == CLRegionStateInside)
    {
            NSLog(@"is in target region");
            UILocalNotification *notification = [[UILocalNotification alloc] init];
            notification.alertBody =  @"You are IN of REGION";
            notification.fireDate = [NSDate date];
            NSTimeZone* timezone = [NSTimeZone defaultTimeZone];
            notification.timeZone = timezone;
            notification.alertAction = @"Show";
            notification.soundName = UILocalNotificationDefaultSoundName;
            [[UIApplication sharedApplication] scheduleLocalNotification:notification];
    }
    else
    {
           NSLog(@"is out of target region");
           UILocalNotification *notification = [[UILocalNotification alloc] init];
            notification.alertBody = @"You are OUT of REGION";
            notification.fireDate = [NSDate date];
            NSTimeZone* timezone = [NSTimeZone defaultTimeZone];
            notification.timeZone = timezone;
            notification.alertAction = @"Show";
            notification.soundName = UILocalNotificationDefaultSoundName;
            [[UIApplication sharedApplication] scheduleLocalNotification:notification];
  }
}

CLLocationManagerが適切に設定されています。私はそれについて調べましたが、私の問題に対する適切な解決策は得られませんでした。誰でも私を助けることができますか?

ありがとう

4

1 に答える 1