ios中的区域监控7 [英] Region monitoring in ios 7

查看:107
本文介绍了ios中的区域监控7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该在我的iOs app中使用区域监控6和7版本。如果我的应用程序关闭,那么系统应该打开它。它适用于iOS 6,但在iOS 7中不起作用。我的意思是,如果应用程序在ios 7中关闭,系统无法打开我的应用程序。

I should use region monitoring in my iOs app for 6 and 7 version. And if my app was closed then system should open it. It works in iOS 6, but not works in iOS 7. I mean, System does not open my app if app was closed in ios 7.

关于关闭应用程序,我意思是,从内存中杀死这个应用程序。

About closing app, I mean, kill this app from memory.

我使用此代码:

manager = [CLLocationManager new];

manager.delegate = self;

[manager startUpdatingLocation];

if ([UIDevice isIOS7OrHigher]) {

    CLCircularRegion *reg = [[CLCircularRegion alloc] initCircularRegionWithCenter:CLLocationCoordinate2DMake(56.844947, 53.208852) radius:20.f identifier:@"reg14132"];

    [manager startMonitoringForRegion:reg];

    CLCircularRegion *reg1 = [[CLCircularRegion alloc] initCircularRegionWithCenter:CLLocationCoordinate2DMake( 56.844158,53.20913) radius:20.f identifier:@"reg14131232"];

    [manager startMonitoringForRegion:reg1];

} else {

    CLRegion *reg = [[CLRegion alloc]  initCircularRegionWithCenter:CLLocationCoordinate2DMake(56.844947, 53.208852) radius:20.f identifier:@"reg14132"];

    [manager startMonitoringForRegion:reg];

    CLRegion *reg1 = [[CLRegion alloc] initCircularRegionWithCenter:CLLocationCoordinate2DMake( 56.844158,53.20913) radius:20.f identifier:@"reg14131232"];
    [manager startMonitoringForRegion:reg1];
}

我使用委托方法进行日志记录。另外,我使用此代码进行测试

And I use delegate methods for log. Also, I use this code for test

if (launchOptions) {
    UILocalNotification *note = [UILocalNotification new];
    note.alertBody = [NSString stringWithFormat:@"launchOptions = %@", launchOptions];
    [[UIApplication sharedApplication] presentLocalNotificationNow:note];
}


推荐答案

这是预期的行为从iOS7开始。在iOS6及更早版本中,即使您从应用程序切换器手动终止应用程序,当用户进入/退出某个区域时,您仍会收到通知。 iOS7的此行为已已更改。如果用户已从应用切换器中杀死了该应用,即通过向上滑动您的应用,则他们将不再接收任何基于位置的通知,包括区域监控通知。 Apple官方开发人员论坛中的Apple员工证实了这一点 - 此处链接

This is now the expected behaviour starting with iOS7. In iOS6 and earlier, even if you manually killed the app from the app-switcher, you would still get a notification when the user entered/exited a region. This behaviour has changed with iOS7. If the user has killed the app from the app-switcher, i.e. by swiping up on your app, then they will no longer receive any location-based notifications, including region monitoring notifications. This was confirmed by an Apple Employee in the official Apple developer forums - link here.

Apple Dev提供的唯一解决方案是请提交错误报告,如果此更改对您有问题,或者您希望看到不同的内容。

The only solution provided by Apple Dev was "Please file bug reports if this change is problematic for you or you would like to see something different."

我个人认为这是一个糟糕的决定,因为它违背了背景通知的目的。您将不得不建议您的用户从iOS6升级,因为他们将继续期望类似的功能,并且此更改未在任何地方记录。

I personally think this was a terrible decision, as it defeats the purpose of background notifications. You will have to advise your users upgrading from iOS6, as they will continue to expect similar functionality and this change has not been documented anywhere.

编辑:正如下面的@herz指出的那样,从iOS 7.1开始,后台监控功能已恢复到iOS 6中的状态。区域将被监控,即使应用程序切换器被杀,您的应用也会收到通知。

EDIT: As @herz below has pointed out, starting in iOS 7.1, the background monitoring functionality has reverted to how it was in iOS 6. Regions will be monitored and your app will receive notifications even when it is killed from the app switcher.

这篇关于ios中的区域监控7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆