More advanced fixes for push notifications on iOS7

This commit is contained in:
Frederic Jacobs 2014-10-30 18:45:14 +01:00
parent f8d201fc52
commit 5091c53aa3
3 changed files with 26 additions and 39 deletions

View File

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

View File

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

View File

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