iphone - 基于位置的通知不会在挂起模式下调用

标签 iphone objective-c ios cllocationmanager

我是基于位置的应用程序的新手。 我的要求是,当用户到达所选区域时,设备必须显示基于位置的通知。 我完美地实现了。此应用程序也在后台运行。 现在我的新要求是,即使在终止应用程序后,设备也必须显示基于位置的通知。 [我看到几个 iPhone 应用程序使用此功能。这些应用程序是“提醒”和“定位器”]。

能否请您检查我的实现步骤如下。

  • 启动应用程序。
  • 选择位置提醒按钮。
  • 调用了以下 CLLocationManager API 来监控我的区域。

    [locationManager startMonitoringForRegion:@"MyRegion"desiredAccuracy:kCLLocationAccuracyBest]; [locationManager startMonitoringSignificantLocationChanges];

  • 退出应用[在后台运行]。

  • 我正在正确接收基于位置的警报通知。

这里是新要求。

  • 启动应用程序。
  • 选择位置提醒按钮。
  • 调用了以下 CLLocationManager API 来监控我的区域。

    [locationManager startMonitoringForRegion:@"MyRegion"desiredAccuracy:kCLLocationAccuracyBest]; [locationManager startMonitoringSignificantLocationChanges];

  • 终止应用程序。 [现在应用程序不在后台运行]

  • 应用应在用户到达位置时显示基于位置的通知。

我如何实现这个逻辑?

最佳答案

嗨, friend 们,我找到了这个问题的解决方案。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

id locationValue = [launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey];
if (locationValue)
{
      [self initLocationMonitoring]; // this will invoke CLLocationManager
}

return YES;
}

关于iphone - 基于位置的通知不会在挂起模式下调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9581509/

相关文章:

iPhone 密码锁定机制

php - IOS app无法显示汉字

ios - “MBProgressHUD 需要在主线程上访问。” - swift 3

ios - 嵌入在 NavigationVC 中的 View 是否可以直接从 master 设置为 splitVC 轮询的详细信息?

iphone - 使用 MFMailComposeViewController 的问题

iphone - 我可以在 iAds 被点击后隐藏它们吗?

iphone - 绘制矩形没有响应

ios - YTPlayerView 视频做了 Ended iOS

ios - 如何根据加载的框架使 Objective-C 类可选?

ios - 这个声明是什么意思?