Skip to content

Commit 13448bd

Browse files
Notifications enhancements.
- Tap to reply to a message. - Badges application with the number of unread messages. - Pick up a phone call from lock screen, or decline it. - Settings for notification sounds while app in foreground and text displayed on local notifications.
1 parent 80b1f2c commit 13448bd

40 files changed

+946
-203
lines changed

Signal.xcodeproj/project.pbxproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@
340340
B640C4771A477B0F005C7C8A /* TSAttachementsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B640C4761A477B0F005C7C8A /* TSAttachementsTest.m */; };
341341
B65031CF1A7862AA002EBBBD /* SignedPreKeyDeletionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B65031CE1A7862AA002EBBBD /* SignedPreKeyDeletionTests.m */; };
342342
B65EDA1219E1BE6400AAA7CB /* RPAPICall.m in Sources */ = {isa = PBXBuildFile; fileRef = B65EDA1119E1BE6400AAA7CB /* RPAPICall.m */; };
343+
B66B9F721AEA6D1100E2E609 /* NotificationSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B66B9F711AEA6D1100E2E609 /* NotificationSettingsViewController.m */; };
344+
B66B9F7D1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B66B9F7C1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.m */; };
343345
B66DBF4A19D5BBC8006EA940 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B66DBF4919D5BBC8006EA940 /* Images.xcassets */; };
344346
B671B2461A93B238002BBD9D /* GroupContactsResult.m in Sources */ = {isa = PBXBuildFile; fileRef = B671B2451A93B238002BBD9D /* GroupContactsResult.m */; };
345347
B67ADDC41989FF8700E1A773 /* RPServerRequestsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B67ADDC31989FF8700E1A773 /* RPServerRequestsManager.m */; };
@@ -405,6 +407,8 @@
405407
B6F509971AA53F760068F56A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B6F509951AA53F760068F56A /* Localizable.strings */; };
406408
B6FAAAE81A41BC6C007FEC1D /* TSAttachmentPointer.m in Sources */ = {isa = PBXBuildFile; fileRef = B6FAAAE71A41BC6C007FEC1D /* TSAttachmentPointer.m */; };
407409
B6FAAAEE1A41C918007FEC1D /* TSAttachmentStream.m in Sources */ = {isa = PBXBuildFile; fileRef = B6FAAAED1A41C918007FEC1D /* TSAttachmentStream.m */; };
410+
B6FE7EB71ADD62FA00A6D22F /* PushKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B6FE7EB61ADD62FA00A6D22F /* PushKit.framework */; };
411+
B6FE7EBA1ADD63AE00A6D22F /* NSData+ows_StripToken.m in Sources */ = {isa = PBXBuildFile; fileRef = B6FE7EB91ADD63AE00A6D22F /* NSData+ows_StripToken.m */; };
408412
B90418E6183E9DD40038554A /* DateUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B90418E5183E9DD40038554A /* DateUtil.m */; };
409413
B90418E7183E9DD40038554A /* DateUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B90418E5183E9DD40038554A /* DateUtil.m */; };
410414
B96A3100187DA1B600648F3E /* HelveticaNeueLTStd-Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = B96A30FE187DA1B600648F3E /* HelveticaNeueLTStd-Bd.otf */; };
@@ -946,6 +950,10 @@
946950
B65EDA1019E1BE6400AAA7CB /* RPAPICall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RPAPICall.h; sourceTree = "<group>"; };
947951
B65EDA1119E1BE6400AAA7CB /* RPAPICall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RPAPICall.m; sourceTree = "<group>"; };
948952
B661C211198EE2EA00548CA1 /* iOSVersions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = iOSVersions.h; path = src/environment/iOSVersions.h; sourceTree = "<group>"; };
953+
B66B9F701AEA6D1100E2E609 /* NotificationSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationSettingsViewController.h; sourceTree = "<group>"; };
954+
B66B9F711AEA6D1100E2E609 /* NotificationSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NotificationSettingsViewController.m; sourceTree = "<group>"; };
955+
B66B9F7B1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationSettingsOptionsViewController.h; sourceTree = "<group>"; };
956+
B66B9F7C1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NotificationSettingsOptionsViewController.m; sourceTree = "<group>"; };
949957
B66DBF4919D5BBC8006EA940 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
950958
B671B2441A93B238002BBD9D /* GroupContactsResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupContactsResult.h; sourceTree = "<group>"; };
951959
B671B2451A93B238002BBD9D /* GroupContactsResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupContactsResult.m; sourceTree = "<group>"; };
@@ -1088,6 +1096,9 @@
10881096
B6FAAAE71A41BC6C007FEC1D /* TSAttachmentPointer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TSAttachmentPointer.m; path = Attachements/TSAttachmentPointer.m; sourceTree = "<group>"; };
10891097
B6FAAAEC1A41C918007FEC1D /* TSAttachmentStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TSAttachmentStream.h; path = Attachements/TSAttachmentStream.h; sourceTree = "<group>"; };
10901098
B6FAAAED1A41C918007FEC1D /* TSAttachmentStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TSAttachmentStream.m; path = Attachements/TSAttachmentStream.m; sourceTree = "<group>"; };
1099+
B6FE7EB61ADD62FA00A6D22F /* PushKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PushKit.framework; path = System/Library/Frameworks/PushKit.framework; sourceTree = SDKROOT; };
1100+
B6FE7EB81ADD63AE00A6D22F /* NSData+ows_StripToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+ows_StripToken.h"; sourceTree = "<group>"; };
1101+
B6FE7EB91ADD63AE00A6D22F /* NSData+ows_StripToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+ows_StripToken.m"; sourceTree = "<group>"; };
10911102
B90418E4183E9DD40038554A /* DateUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateUtil.h; sourceTree = "<group>"; };
10921103
B90418E5183E9DD40038554A /* DateUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DateUtil.m; sourceTree = "<group>"; };
10931104
B96A30FE187DA1B600648F3E /* HelveticaNeueLTStd-Bd.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "HelveticaNeueLTStd-Bd.otf"; sourceTree = "<group>"; };
@@ -1227,6 +1238,7 @@
12271238
isa = PBXFrameworksBuildPhase;
12281239
buildActionMask = 2147483647;
12291240
files = (
1241+
B6FE7EB71ADD62FA00A6D22F /* PushKit.framework in Frameworks */,
12301242
FC3BD9881A30A790005B96BB /* Social.framework in Frameworks */,
12311243
FCB11D8C1A129A76002F93FB /* CoreMedia.framework in Frameworks */,
12321244
70377AAB1918450100CAF501 /* MobileCoreServices.framework in Frameworks */,
@@ -1750,6 +1762,8 @@
17501762
76EB04C818170B33006006FC /* util */ = {
17511763
isa = PBXGroup;
17521764
children = (
1765+
B6FE7EB81ADD63AE00A6D22F /* NSData+ows_StripToken.h */,
1766+
B6FE7EB91ADD63AE00A6D22F /* NSData+ows_StripToken.m */,
17531767
A59E6D701A79E5D100D98E2E /* MIMETypeUtil.h */,
17541768
A59E6D711A79E5D100D98E2E /* MIMETypeUtil.m */,
17551769
FCFA64B11A24F29E0007FB87 /* UI Categories */,
@@ -2449,6 +2463,7 @@
24492463
D221A08C169C9E5E00537ABF /* Frameworks */ = {
24502464
isa = PBXGroup;
24512465
children = (
2466+
B6FE7EB61ADD62FA00A6D22F /* PushKit.framework */,
24522467
FC3BD9871A30A790005B96BB /* Social.framework */,
24532468
B60EDE031A05A01700D73516 /* AudioToolbox.framework */,
24542469
FCB11D8B1A129A76002F93FB /* CoreMedia.framework */,
@@ -2594,6 +2609,10 @@
25942609
FCD274E11A5AFD8000202277 /* PrivacySettingsTableViewController.m */,
25952610
FCD274E61A5AFDC900202277 /* AdvancedSettingsTableViewController.h */,
25962611
FCD274E71A5AFDC900202277 /* AdvancedSettingsTableViewController.m */,
2612+
B66B9F701AEA6D1100E2E609 /* NotificationSettingsViewController.h */,
2613+
B66B9F711AEA6D1100E2E609 /* NotificationSettingsViewController.m */,
2614+
B66B9F7B1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.h */,
2615+
B66B9F7C1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.m */,
25972616
FCD274E91A5AFDDB00202277 /* AboutTableViewController.h */,
25982617
FCD274EA1A5AFDDB00202277 /* AboutTableViewController.m */,
25992618
);
@@ -2981,6 +3000,7 @@
29813000
B63AF5C71A1F757900D01AAD /* TSContactsIntersectionRequest.m in Sources */,
29823001
B6B0968B1A1D25ED008BFAA6 /* TSStorageManager+SignedPreKeyStore.m in Sources */,
29833002
76EB05AC18170B33006006FC /* SrtpSocket.m in Sources */,
3003+
B6FE7EBA1ADD63AE00A6D22F /* NSData+ows_StripToken.m in Sources */,
29843004
B6A5D05C1A7827ED0043D837 /* TSAvailablePreKeysCountRequest.m in Sources */,
29853005
FCB11D931A12A4AA002F93FB /* FullImageViewController.m in Sources */,
29863006
B6B096871A1D25ED008BFAA6 /* TSStorageManager+IdentityKeyStore.m in Sources */,
@@ -3058,6 +3078,7 @@
30583078
FCAC963C19FEF9280046DFC5 /* SignalsViewController.m in Sources */,
30593079
76EB05DA18170B33006006FC /* LowLatencyConnector.m in Sources */,
30603080
76EB05EE18170B33006006FC /* CallTermination.m in Sources */,
3081+
B66B9F7D1AEAF40500E2E609 /* NotificationSettingsOptionsViewController.m in Sources */,
30613082
E1CD329618BCFF9900B1A496 /* SoundInstance.m in Sources */,
30623083
B6FAAAEE1A41C918007FEC1D /* TSAttachmentStream.m in Sources */,
30633084
76EB05B418170B33006006FC /* HashChain.m in Sources */,
@@ -3128,6 +3149,7 @@
31283149
B6FAAAE81A41BC6C007FEC1D /* TSAttachmentPointer.m in Sources */,
31293150
B6B096881A1D25ED008BFAA6 /* TSStorageManager+keyFromIntLong.m in Sources */,
31303151
B6B50AAB1A4192C500F8F607 /* TSMessagesManager+attachments.m in Sources */,
3152+
B66B9F721AEA6D1100E2E609 /* NotificationSettingsViewController.m in Sources */,
31313153
76EB059018170B33006006FC /* IgnoredPacketFailure.m in Sources */,
31323154
B60FB9B01A4711D4006A5A66 /* TSAttachmentEncryptionResult.m in Sources */,
31333155
76EB05D418170B33006006FC /* ZrtpManager.m in Sources */,

Signal/Signal-Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<key>CFBundlePackageType</key>
2222
<string>APPL</string>
2323
<key>CFBundleShortVersionString</key>
24-
<string>2.0.3</string>
24+
<string>2.1</string>
2525
<key>CFBundleSignature</key>
2626
<string>????</string>
2727
<key>CFBundleURLTypes</key>
@@ -38,7 +38,7 @@
3838
</dict>
3939
</array>
4040
<key>CFBundleVersion</key>
41-
<string>2.0.20</string>
41+
<string>2.0.21</string>
4242
<key>LOGS_EMAIL</key>
4343
<string>[email protected]</string>
4444
<key>LOGS_URL</key>

Signal/src/AppDelegate.m

Lines changed: 47 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
#import "DebugLogger.h"
66
#import "DiscardingLog.h"
77
#import "Environment.h"
8-
#import "InCallViewController.h"
8+
#import "PhoneNumberDirectoryFilterManager.h"
99
#import "PreferencesUtil.h"
10-
#import "NotificationTracker.h"
1110
#import "PushManager.h"
1211
#import "PriorityQueue.h"
1312
#import "Release.h"
1413
#import "SignalsViewController.h"
1514
#import "TSAccountManager.h"
1615
#import "TSPreKeyManager.h"
16+
#import "TSMessagesManager.h"
1717
#import "TSSocketManager.h"
1818
#import "TSStorageManager.h"
1919
#import "Util.h"
@@ -28,10 +28,7 @@
2828

2929
@interface AppDelegate ()
3030

31-
@property (nonatomic, retain) UIWindow *blankWindow;
32-
@property (nonatomic, strong) NotificationTracker *notificationTracker;
33-
34-
@property (nonatomic) TOCFutureSource *callPickUpFuture;
31+
@property (nonatomic, retain) UIWindow *blankWindow;
3532

3633
@end
3734

@@ -68,12 +65,12 @@ - (BOOL) isVersion:(NSString *)thisVersionString lessThan:(NSString *)thatVersio
6865
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
6966
[self setupAppearance];
7067

68+
[[PushManager sharedManager] registerPushKitNotificationFuture];
69+
7170
if (getenv("runningTests_dontStartApp")) {
7271
return YES;
7372
}
7473

75-
self.notificationTracker = [NotificationTracker notificationTracker];
76-
7774
CategorizingLogger* logger = [CategorizingLogger categorizingLogger];
7875
[logger addLoggingCallback:^(NSString *category, id details, NSUInteger index) {}];
7976
[Environment setCurrent:[Release releaseEnvironmentWithLogging:logger]];
@@ -119,7 +116,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
119116
[self prepareScreenshotProtection];
120117

121118
if ([TSAccountManager isRegistered]) {
122-
[TSSocketManager becomeActive];
119+
if ([self applicationIsActive]) {
120+
[TSSocketManager becomeActiveFromForeground];
121+
}
123122
[[PushManager sharedManager] validateUserNotificationSettings];
124123
[self refreshContacts];
125124
[TSPreKeyManager refreshPreKeys];
@@ -172,85 +171,27 @@ -(BOOL) application:(UIApplication*)application openURL:(NSURL*)url sourceApplic
172171
return NO;
173172
}
174173

175-
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
176-
if ([self isRedPhonePush:userInfo]) {
177-
ResponderSessionDescriptor* call;
178-
if (![self.notificationTracker shouldProcessNotification:userInfo]){
179-
return;
180-
}
181-
182-
@try {
183-
call = [ResponderSessionDescriptor responderSessionDescriptorFromEncryptedRemoteNotification:userInfo];
184-
DDLogDebug(@"Received remote notification. Parsed session descriptor: %@.", call);
185-
self.callPickUpFuture = [TOCFutureSource new];
186-
} @catch (OperationFailed* ex) {
187-
DDLogError(@"Error parsing remote notification. Error: %@.", ex);
188-
return;
189-
}
190-
191-
if (!call) {
192-
DDLogError(@"Decryption of session descriptor failed");
193-
return;
194-
}
195-
196-
[Environment.phoneManager incomingCallWithSession:call];
197-
}
198-
}
199-
200-
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
201-
202-
if ([self isRedPhonePush:userInfo]) {
203-
[self application:application didReceiveRemoteNotification:userInfo];
204-
} else {
205-
[TSSocketManager becomeActive];
174+
-(void)applicationDidBecomeActive:(UIApplication *)application {
175+
if ([TSAccountManager isRegistered] && [self applicationIsActive]) {
176+
// We're double checking that the app is active, to be sure since we can't verify in production env due to code signing.
177+
[TSSocketManager becomeActiveFromForeground];
206178
}
207179

208-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC),
209-
dispatch_get_main_queue(), ^{
210-
completionHandler(UIBackgroundFetchResultNewData);
211-
});
180+
[self removeScreenProtection];
212181
}
213182

214-
- (BOOL)isRedPhonePush:(NSDictionary*)pushDict {
215-
NSDictionary *aps = [pushDict objectForKey:@"aps"];
216-
NSString *category = [aps objectForKey:@"category"];
217-
218-
if ([category isEqualToString:Signal_Call_Category]) {
219-
return YES;
220-
} else{
221-
return NO;
222-
}
223-
}
183+
- (void)applicationWillResignActive:(UIApplication *)application {
184+
[self protectScreen];
224185

225-
-(void) applicationDidBecomeActive:(UIApplication *)application {
226186
if ([TSAccountManager isRegistered]) {
227-
[TSSocketManager becomeActive];
187+
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
188+
[self updateBadge];
228189
}
229-
// Hacky way to clear notification center after processed push
230-
[UIApplication.sharedApplication setApplicationIconBadgeNumber:1];
231-
[UIApplication.sharedApplication setApplicationIconBadgeNumber:0];
232-
233-
[self removeScreenProtection];
234-
}
235-
236-
- (void)applicationWillResignActive:(UIApplication *)application{
237-
[self protectScreen];
238190
}
239191

240-
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler{
241-
242-
[self application:application didReceiveRemoteNotification:userInfo];
243-
if ([identifier isEqualToString:Signal_Call_Accept_Identifier]) {
244-
[self.callPickUpFuture trySetResult:@YES];
245-
completionHandler();
246-
} else if ([identifier isEqualToString:Signal_Call_Decline_Identifier]){
247-
[self.callPickUpFuture trySetResult:@NO];
248-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC),
249-
dispatch_get_main_queue(), ^{
250-
completionHandler();
251-
});
252-
} else{
253-
completionHandler();
192+
- (void)updateBadge {
193+
if ([TSAccountManager isRegistered]) {
194+
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:(NSInteger)[[TSMessagesManager sharedManager] unreadMessagesCount]];
254195
}
255196
}
256197

@@ -329,4 +270,31 @@ - (void)refreshContacts {
329270
[manager forceUpdate];
330271
}
331272

273+
#pragma mark Push Notifications Delegate Methods
274+
275+
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
276+
[[PushManager sharedManager] application:application didReceiveRemoteNotification:userInfo];
277+
}
278+
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
279+
[[PushManager sharedManager] application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
280+
}
281+
282+
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
283+
[[PushManager sharedManager] application:application didReceiveLocalNotification:notification];
284+
}
285+
286+
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler {
287+
[[PushManager sharedManager] application:application handleActionWithIdentifier:identifier forLocalNotification:notification completionHandler:completionHandler];
288+
}
289+
290+
- (BOOL)applicationIsActive {
291+
UIApplication *app = [UIApplication sharedApplication];
292+
293+
if (app.applicationState == UIApplicationStateActive) {
294+
return YES;
295+
}
296+
297+
return NO;
298+
}
299+
332300
@end

0 commit comments

Comments
 (0)