diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index e7f1f3a8f..e47399805 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -84,9 +84,7 @@ // start register for apn id futureApnIdSource = [FutureSource new]; - [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge - | UIRemoteNotificationTypeSound - | UIRemoteNotificationTypeAlert)]; + [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound| UIRemoteNotificationTypeAlert)]; CategorizingLogger* logger = [CategorizingLogger categorizingLogger]; [logger addLoggingCallback:^(NSString *category, id details, NSUInteger index) {}]; @@ -121,21 +119,21 @@ } - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken { + DDLogDebug(@"Device registered for push"); [futureApnIdSource trySetResult:deviceToken]; } - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error { + DDLogError(@"Failed to register for push notifications: %@", error); [futureApnIdSource trySetFailure:error]; } -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { - id apnLogger = [[Environment logging] getConditionLoggerForSender:application]; - ResponderSessionDescriptor* call; @try { call = [ResponderSessionDescriptor responderSessionDescriptorFromEncryptedRemoteNotification:userInfo]; - [apnLogger logNotice:[NSString stringWithFormat:@"Received remote notification. Parsed session descriptor: %@. Notication: %@.", call, userInfo]]; + DDLogDebug(@"Received remote notification. Parsed session descriptor: %@.", call); } @catch (OperationFailed* ex) { - [apnLogger logWarning:[NSString stringWithFormat:@"Error parsing remote notification. Error: %@. Notifaction: %@.", ex, userInfo]]; + DDLogError(@"Error parsing remote notification. Error: %@.", ex); return; } @@ -145,6 +143,8 @@ -(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { if([self.notificationTracker shouldProcessNotification:userInfo]){ [self application:application didReceiveRemoteNotification:userInfo]; + } else{ + DDLogDebug(@"Push already processed. Skipping."); } completionHandler(UIBackgroundFetchResultNewData); } diff --git a/Signal/src/NotificationTracker.m b/Signal/src/NotificationTracker.m index 2145c673b..ff64bdc5c 100644 --- a/Signal/src/NotificationTracker.m +++ b/Signal/src/NotificationTracker.m @@ -27,7 +27,7 @@ NSData* data = [self getIdForNotification:notification]; [_witnessedNotifications insertObject:data atIndex:0]; - while( MAX_NOTIFICATIONS_TO_TRACK < [_witnessedNotifications count]){ + while(MAX_NOTIFICATIONS_TO_TRACK < [_witnessedNotifications count]){ [_witnessedNotifications removeLastObject]; } } diff --git a/Signal/src/phone/signaling/ResponderSessionDescriptor.m b/Signal/src/phone/signaling/ResponderSessionDescriptor.m index b2fd70516..de4633f47 100644 --- a/Signal/src/phone/signaling/ResponderSessionDescriptor.m +++ b/Signal/src/phone/signaling/ResponderSessionDescriptor.m @@ -59,6 +59,7 @@ NSData* encryptedPayload = [self verifyAndRemoveMacFromRemoteNotifcationData:authenticatedPayload]; NSData* payload = [self decryptRemoteNotificationData:encryptedPayload]; + InitiateSignal* parsedPayload = [InitiateSignal parseFromData:payload]; in_port_t maxPort = (in_port_t)-1; @@ -76,6 +77,8 @@ NSString* relayServerName = parsedPayload.serverName; PhoneNumber* phoneNumber = [PhoneNumber phoneNumberFromE164:parsedPayload.initiator]; + DDLogDebug(@"Initiating call with session descriptor: %i UDP-Port:%hu sessionID:%lld, relayServerName:%@", interopVersion, relayUdpPort, sessionId, relayServerName); + return [ResponderSessionDescriptor responderSessionDescriptorWithInteropVersion:interopVersion andRelayUdpPort:relayUdpPort andSessionId:sessionId diff --git a/Signal/src/util/constraints/Constraints.h b/Signal/src/util/constraints/Constraints.h index 57eddf40a..b23344212 100644 --- a/Signal/src/util/constraints/Constraints.h +++ b/Signal/src/util/constraints/Constraints.h @@ -5,7 +5,7 @@ /// 'require(X)' is used to indicate parameter-related preconditions that callers must satisfy. /// Failure to satisfy indicates a bug in the caller. -#define require(expr) if (!(expr)) [BadArgument raise:[NSString stringWithFormat:@"require %@ (in %s at line %d)", (@#expr), __FILE__, __LINE__]] +#define require(expr) if (!(expr)){ NSString *reason = [NSString stringWithFormat:@"require %@ (in %s at line %d)", (@#expr), __FILE__, __LINE__]; DDLogError(@"%@", reason);[BadArgument raise:reason];}; /// 'requireState(X)' is used to indicate callee-state-related preconditions that callers must satisfy. /// Failure to satisfy indicates a stateful bug in either the caller or the callee. @@ -14,7 +14,7 @@ /// 'checkOperation(X)' is used to throw exceptions if operations fail. /// Failure does not indicate a bug. /// Methods may throw these exceptions for callers to catch as a 'returned error' result. -#define checkOperation(expr) if (!(expr)) [OperationFailed raise:[NSString stringWithFormat:@"Operation failed. Expected: %@(in %s at line %d)", (@#expr),__FILE__,__LINE__]] +#define checkOperation(expr) if (!(expr)){ NSString *reason = [NSString stringWithFormat:@"Operation failed. Expected: %@(in %s at line %d)", (@#expr),__FILE__,__LINE__];[OperationFailed raise:reason];} /// 'checkOperationDescribe(X, Desc)' is used to throw exceptions if operations fail, and describe the problem. /// Failure does not indicate a bug. diff --git a/Signal/src/view controllers/RegisterViewController.m b/Signal/src/view controllers/RegisterViewController.m index 1bc4d3262..b0e998249 100644 --- a/Signal/src/view controllers/RegisterViewController.m +++ b/Signal/src/view controllers/RegisterViewController.m @@ -191,7 +191,7 @@ [_challengeTextField resignFirstResponder]; _challengeButton.enabled = NO; [_challengeActivityIndicator startAnimating]; - + HttpRequest *verifyRequest = [HttpRequest httpRequestToVerifyAccessToPhoneNumberWithChallenge:_challengeTextField.text]; Future *futureDone = [HttpManager asyncOkResponseFromMasterServer:verifyRequest unlessCancelled:nil