|
24 | 24 | #import "NCNavigationController.h" |
25 | 25 | #import "NCNotificationController.h" |
26 | 26 | #import "NCPushNotification.h" |
27 | | -#import "NCPushNotificationsUtils.h" |
28 | 27 | #import "NCRoomsManager.h" |
29 | 28 | #import "NCSettingsController.h" |
30 | 29 | #import "NCUserInterfaceController.h" |
@@ -344,16 +343,19 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N |
344 | 343 | { |
345 | 344 | // Called when a background notification is delivered. |
346 | 345 | NSString *message = [userInfo objectForKey:@"subject"]; |
| 346 | + NSString *signature = [userInfo objectForKey:@"signature"]; |
| 347 | + |
| 348 | + if (!message || !signature) { |
| 349 | + return; |
| 350 | + } |
| 351 | + |
347 | 352 | for (TalkAccount *account in [[NCDatabaseManager sharedInstance] allAccounts]) { |
348 | | - NSData *pushNotificationPrivateKey = [[NCKeyChainController sharedInstance] pushNotificationPrivateKeyForAccountId:account.accountId]; |
349 | | - if (message && pushNotificationPrivateKey) { |
350 | | - NSString *decryptedMessage = [NCPushNotificationsUtils decryptPushNotification:message withDevicePrivateKey:pushNotificationPrivateKey]; |
351 | | - if (decryptedMessage) { |
352 | | - NCPushNotification *pushNotification = [NCPushNotification pushNotificationFromDecryptedString:decryptedMessage withAccountId:account.accountId]; |
353 | | - [[NCNotificationController sharedInstance] processBackgroundPushNotification:pushNotification]; |
354 | | - |
355 | | - break; |
356 | | - } |
| 353 | + NSString *decryptedMessage = [NCPushNotificationsUtils decryptPushNotificationWithMessageBase64:message withSignatureBase64:signature forAccount:account]; |
| 354 | + if (decryptedMessage) { |
| 355 | + NCPushNotification *pushNotification = [NCPushNotification pushNotificationFromDecryptedString:decryptedMessage withAccountId:account.accountId]; |
| 356 | + [[NCNotificationController sharedInstance] processBackgroundPushNotification:pushNotification]; |
| 357 | + |
| 358 | + break; |
357 | 359 | } |
358 | 360 | } |
359 | 361 |
|
@@ -382,25 +384,23 @@ - (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayloa |
382 | 384 | [NCUtils log:@"Received PushKit notification"]; |
383 | 385 |
|
384 | 386 | NSString *message = [payload.dictionaryPayload objectForKey:@"subject"]; |
385 | | - for (TalkAccount *account in [[NCDatabaseManager sharedInstance] allAccounts]) { |
386 | | - NSData *pushNotificationPrivateKey = [[NCKeyChainController sharedInstance] pushNotificationPrivateKeyForAccountId:account.accountId]; |
| 387 | + NSString *signature = [payload.dictionaryPayload objectForKey:@"signature"]; |
387 | 388 |
|
388 | | - if (!message || !pushNotificationPrivateKey) { |
389 | | - continue; |
390 | | - } |
391 | | - |
392 | | - NSString *decryptedMessage = [NCPushNotificationsUtils decryptPushNotification:message withDevicePrivateKey:pushNotificationPrivateKey]; |
| 389 | + if (message && signature) { |
| 390 | + for (TalkAccount *account in [[NCDatabaseManager sharedInstance] allAccounts]) { |
| 391 | + NSString *decryptedMessage = [NCPushNotificationsUtils decryptPushNotificationWithMessageBase64:message withSignatureBase64:signature forAccount:account]; |
393 | 392 |
|
394 | | - if (!decryptedMessage) { |
395 | | - continue; |
396 | | - } |
| 393 | + if (!decryptedMessage) { |
| 394 | + continue; |
| 395 | + } |
397 | 396 |
|
398 | | - NCPushNotification *pushNotification = [NCPushNotification pushNotificationFromDecryptedString:decryptedMessage withAccountId:account.accountId]; |
| 397 | + NCPushNotification *pushNotification = [NCPushNotification pushNotificationFromDecryptedString:decryptedMessage withAccountId:account.accountId]; |
399 | 398 |
|
400 | | - if ( pushNotification && pushNotification.type == NCPushNotificationTypeCall) { |
401 | | - [[NCNotificationController sharedInstance] showIncomingCallForPushNotification:pushNotification]; |
402 | | - completion(); |
403 | | - return; |
| 399 | + if (pushNotification && pushNotification.type == NCPushNotificationTypeCall) { |
| 400 | + [[NCNotificationController sharedInstance] showIncomingCallForPushNotification:pushNotification]; |
| 401 | + completion(); |
| 402 | + return; |
| 403 | + } |
404 | 404 | } |
405 | 405 | } |
406 | 406 |
|
|
0 commit comments