More advanced fixes for push notifications on iOS7

pull/1/head
Frederic Jacobs 11 years ago
parent f8d201fc52
commit 5091c53aa3

@ -20,17 +20,8 @@
#import "Util.h" #import "Util.h"
#import "VersionMigrations.h" #import "VersionMigrations.h"
#import <PastelogKit/Pastelog.h> #import <PastelogKit/Pastelog.h>
#define kSignalVersionKey @"SignalUpdateVersionKey" #define kSignalVersionKey @"SignalUpdateVersionKey"
#ifdef __APPLE__ #ifdef __APPLE__

@ -111,6 +111,9 @@
if (SYSTEM_VERSION_LESS_THAN(_iOS_8_0)) { if (SYSTEM_VERSION_LESS_THAN(_iOS_8_0)) {
[UIApplication.sharedApplication registerForRemoteNotificationTypes:(UIRemoteNotificationType)self.mandatoryNotificationTypes]; [UIApplication.sharedApplication registerForRemoteNotificationTypes:(UIRemoteNotificationType)self.mandatoryNotificationTypes];
if ([self isMissingMandatoryNotificationTypes]) {
[self.pushNotificationFutureSource trySetFailure:@"Missing Types"];
}
} else { } else {
[UIApplication.sharedApplication registerForRemoteNotifications]; [UIApplication.sharedApplication registerForRemoteNotifications];
} }
@ -175,8 +178,6 @@
} else{ } else{
return self.wantRemoteNotifications && (!UIApplication.sharedApplication.isRegisteredForRemoteNotifications); return self.wantRemoteNotifications && (!UIApplication.sharedApplication.isRegisteredForRemoteNotifications);
} }
} }
-(BOOL) wantRemoteNotifications { -(BOOL) wantRemoteNotifications {

@ -170,22 +170,17 @@
} failure:^(NSURLSessionDataTask *task, NSError *error) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
NSString *alertTitle = NSLocalizedString(@"REGISTRATION_ERROR", @""); NSString *alertTitle = NSLocalizedString(@"REGISTRATION_ERROR", @"");
if ([error isKindOfClass:HttpResponse.class]) { NSHTTPURLResponse* badResponse = (NSHTTPURLResponse*)task.response;
NSHTTPURLResponse* badResponse = (NSHTTPURLResponse*)task.response; if (badResponse.statusCode == 401) {
if (badResponse.statusCode == 401) { SignalAlertView(alertTitle, REGISTER_CHALLENGE_ALERT_VIEW_BODY);
SignalAlertView(alertTitle, REGISTER_CHALLENGE_ALERT_VIEW_BODY); } else if (badResponse.statusCode == 401){
} else if (badResponse.statusCode == 401){ SignalAlertView(alertTitle, NSLocalizedString(@"REGISTER_RATE_LIMITING_BODY", @""));
SignalAlertView(alertTitle, NSLocalizedString(@"REGISTER_RATE_LIMITING_BODY", @"")); } else {
} else { NSString *alertBodyString = [NSString stringWithFormat:@"%@ %lu", NSLocalizedString(@"SERVER_CODE", @""),(unsigned long)badResponse.statusCode];
NSString *alertBodyString = [NSString stringWithFormat:@"%@ %lu", NSLocalizedString(@"SERVER_CODE", @""),(unsigned long)badResponse.statusCode]; SignalAlertView (alertTitle, alertBodyString);
SignalAlertView (alertTitle, alertBodyString);
}
} else{
Environment.errorNoter(error, @"While Verifying Challenge.", NO);
SignalReportError
} }
_challengeButton.enabled = YES; _challengeButton.enabled = YES;
[_challengeActivityIndicator stopAnimating]; [_challengeActivityIndicator stopAnimating];
}]; }];
} }

Loading…
Cancel
Save