【问题标题】:GEO-reminders launching appGEO-提醒启动应用程序
【发布时间】:2012-07-27 16:17:57
【问题描述】:

我正在考虑使用 GEO 提醒的应用程序(iOS5 中添加的那些,在我离开/到达时在某个位置提醒我)。但是我需要使用此功能(实际上,仅使用位置)来获取当前位置并将其与我的应用程序定义的位置进行比较,并检查它是否相同。如果当前位置和定义的位置相同,请启动我的应用程序。

这可能吗?

我希望你能理解我的目的。 提前致谢

【问题讨论】:

    标签: iphone ios geolocation reminders app-launcher


    【解决方案1】:

    虽然您可以从后台监控您的位置,但请注意,它不会自动启动您的应用。您可以使用诸如本地通知之类的东西来提示用户打开应用程序。但是从后台自动启动不是一种选择。至少不是 App Store 认可的选项。

    【讨论】:

      【解决方案2】:

      当您设置要监控的区域时,会自动检查当前区域和已定义区域。最好的起点是阅读CLLocationManagerDelegate 的文档,尤其是startMonitoringForRegion:。你想做的事情叫做“地理围栏”。您还可以在Location Awareness guide 中找到更多信息。

      【讨论】:

      • 虽然这很有用,但我要求的是自动启动我的应用程序。所以+1,但接受的答案是比尔伯吉斯的答案。谢谢你的信息!
      • 没问题。正如比尔所说,应用程序启动的工作方式是您收到本地通知。您的应用可能会在没有用户交互的情况下被唤醒,此时您可以做一些工作。
      【解决方案3】:

      作为 iPhone 开发的新手,我不知道如何以编程方式为应用程序提供午餐,但我可以帮助您解决到达预定义位置的触发器。这是代码。

      1:导入CoreLocation.framework

      2:在 viewController.h 文件中的代码下方

      #import <UIKit/UIKit.h>
      #import <CoreLocation/CoreLocation.h>
      @interface ViewController : UIViewController<CLLocationManagerDelegate>
      @end
      

      3:inviewController.m

      #import "ViewController.h"
      @interface ViewController (){
      CLLocationManager *locationManager;
      CLRegion *mexicoBoundary;
      }
      
      @end
      
      @implementation ViewController
      
      - (void)viewDidLoad
      {
         [super viewDidLoad];
      
      locationManager = [[CLLocationManager alloc] init];
      [locationManager setDelegate:self];
      [locationManager setDistanceFilter:kCLDistanceFilterNone];
      
      
      
      CLLocationCoordinate2D regionCords ;
      //19.432608,-99.133208 lat, lon for mexico city
      regionCords=CLLocationCoordinate2DMake(19.432608,-99.133208);
      //5000 below, is in meters-radius 
      mexicoBoundary =
      [[CLRegion alloc]initCircularRegionWithCenter:regionCords
                                             radius:5000.0
                                         identifier:@"mexico_Day"];
      
      [locationManager startMonitoringForRegion:mexicoBoundary];
      
      }
      
      -(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
      {
      NSLog(@"%@: %@", @"region entered", region.identifier);
      
      }
      
      -(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
      {
      NSLog(@"%@: %@", @"region exited", region.identifier);
      }
      
      
      
      - (void)didReceiveMemoryWarning
      {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
      }
      
      @end
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-13
        • 1970-01-01
        • 1970-01-01
        • 2016-08-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多