Created
March 21, 2016 05:41
-
-
Save Qata/6700669f22ac0a16c4e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)installWiFiStatusChangedAlertView:(UIViewController *)viewController | |
{ | |
[[[RPCController WiFiStatusChanged] filter:^BOOL(id value) { | |
return ![RPCController isWiFiEnabled] || ![RPCController isWiFiConnected]; | |
}] subscribeNext:^(id _) { | |
NSString *title = nil; | |
NSString *message = nil; | |
if (![RPCController isWiFiEnabled]) | |
{ | |
title = NSLocalizedString(@"WiFi is disabled", nil); | |
message = NSLocalizedString(@"To make use of this application, please enable your WiFi and connect to a WiFi network", nil); | |
} | |
else | |
{ | |
title = NSLocalizedString(@"You're not connected to a WiFi network", nil); | |
message = NSLocalizedString(@"To make use of this application, please connect to a WiFi network", nil); | |
} | |
UIAlertController * controller = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; | |
[controller rac_liftSelector:@selector(dismissViewControllerAnimated:completion:) withSignalsFromArray:@[[[[RPCController WiFiStatusChanged] ignore:@NO] takeUntil:controller.rac_willDeallocSignal], [RACSignal return:nil]]]; | |
[controller addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleCancel handler:nil]]; | |
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) | |
{ | |
[controller addAction:[UIAlertAction actionWithTitle:@"Settings..." style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { | |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; | |
}]]; | |
} | |
[viewController presentViewController:controller animated:YES completion:nil]; | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment