Ios 在后台运行应用程序时检测Wi-Fi网络变化
我发现自2011年以来没有答案,建议使用apple示例代码从iOS应用程序检测网络发生变化时(在后台运行时) 我需要能够这样做,而应用程序是在后台,但代码样本没有显示后台执行 你知道我该怎么做吗 这是我到目前为止编写的AppDelegate代码:Ios 在后台运行应用程序时检测Wi-Fi网络变化,ios,objective-c,iphone,network-programming,Ios,Objective C,Iphone,Network Programming,我发现自2011年以来没有答案,建议使用apple示例代码从iOS应用程序检测网络发生变化时(在后台运行时) 我需要能够这样做,而应用程序是在后台,但代码样本没有显示后台执行 你知道我该怎么做吗 这是我到目前为止编写的AppDelegate代码: #import "APLAppDelegate.h" //#import "Reachability.h" @implementation APLAppDelegate @synthesize reachability; - (BOOL)appli
#import "APLAppDelegate.h"
//#import "Reachability.h"
@implementation APLAppDelegate
@synthesize reachability;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize Reachability
//Reachability *
reachability = [Reachability reachabilityForLocalWiFi];
return YES;
}
- (void) applicationDidEnterBackground:(UIApplication *)application{
// Start Monitoring
[reachability startNotifier];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityDidChange:) name:kReachabilityChangedNotification object:nil];
}
- (void)reachabilityDidChange:(NSNotification *)notification {
//Reachability *reachability = (Reachability *)[notification object];
Reachability *reachability = (Reachability *)[notification object];
}
检查此项我以前使用过,但在后台检查时没有解释太多。@mm24您找到解决方案了吗?我正在使用NSURLSessionConfiguration Downloadtask,需要在后台出现网络断开连接时取消它。我需要在后台获得网络更改通知,因此我可以取消请求。检查此项我以前使用过它,但在后台检查此项时没有解释太多。@mm24您找到解决方案了吗?我正在使用NSURLSessionConfiguration Downloadtask,需要在后台出现网络断开连接时取消它。我需要在后台获得网络更改通知,因此我可以取消请求。