|
@@ -54,8 +54,8 @@
|
|
|
|
|
|
for (tableAccount *result in [[NCManageDatabase shared] getAllAccount]) {
|
|
for (tableAccount *result in [[NCManageDatabase shared] getAllAccount]) {
|
|
|
|
|
|
- NSString *token = [CCUtility getPushNotificationToken:result.account];
|
|
|
|
-
|
|
|
|
|
|
+ NSString *token = [[[NCKeychain alloc] init] getPushNotificationTokenWithAccount:result.account];
|
|
|
|
+
|
|
if (![token isEqualToString:self.pushKitToken]) {
|
|
if (![token isEqualToString:self.pushKitToken]) {
|
|
if (token != nil) {
|
|
if (token != nil) {
|
|
// unsubscribing + subscribing
|
|
// unsubscribing + subscribing
|
|
@@ -73,8 +73,8 @@
|
|
if (message) {
|
|
if (message) {
|
|
NSArray *results = [[NCManageDatabase shared] getAllAccount];
|
|
NSArray *results = [[NCManageDatabase shared] getAllAccount];
|
|
for (tableAccount *result in results) {
|
|
for (tableAccount *result in results) {
|
|
- if ([CCUtility getPushNotificationPrivateKey:result.account]) {
|
|
|
|
- NSData *decryptionKey = [CCUtility getPushNotificationPrivateKey:result.account];
|
|
|
|
|
|
+ if ([[[NCKeychain alloc] init] getPushNotificationPrivateKeyWithAccount:result.account]) {
|
|
|
|
+ NSData *decryptionKey = [[[NCKeychain alloc] init] getPushNotificationPrivateKeyWithAccount:result.account];
|
|
NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:decryptionKey];
|
|
NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:decryptionKey];
|
|
if (decryptedMessage) {
|
|
if (decryptedMessage) {
|
|
NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
|
|
NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
|
|
@@ -102,7 +102,7 @@
|
|
[[NCPushNotificationEncryption shared] generatePushNotificationsKeyPair:account];
|
|
[[NCPushNotificationEncryption shared] generatePushNotificationsKeyPair:account];
|
|
|
|
|
|
NSString *pushTokenHash = [[NCEndToEndEncryption sharedManager] createSHA512:self.pushKitToken];
|
|
NSString *pushTokenHash = [[NCEndToEndEncryption sharedManager] createSHA512:self.pushKitToken];
|
|
- NSData *pushPublicKey = [CCUtility getPushNotificationPublicKey:account];
|
|
|
|
|
|
+ NSData *pushPublicKey = [[[NCKeychain alloc] init] getPushNotificationPublicKeyWithAccount:account];
|
|
NSString *pushDevicePublicKey = [[NSString alloc] initWithData:pushPublicKey encoding:NSUTF8StringEncoding];
|
|
NSString *pushDevicePublicKey = [[NSString alloc] initWithData:pushPublicKey encoding:NSUTF8StringEncoding];
|
|
NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
|
|
NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
|
|
|
|
|
|
@@ -114,10 +114,10 @@
|
|
|
|
|
|
[[[NextcloudKit shared] nkCommonInstance] writeLog:@"[INFO] Subscribed to Push Notification server & proxy successfully"];
|
|
[[[NextcloudKit shared] nkCommonInstance] writeLog:@"[INFO] Subscribed to Push Notification server & proxy successfully"];
|
|
|
|
|
|
- [CCUtility setPushNotificationToken:account token:self.pushKitToken];
|
|
|
|
- [CCUtility setPushNotificationDeviceIdentifier:account deviceIdentifier:deviceIdentifier];
|
|
|
|
- [CCUtility setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:signature];
|
|
|
|
- [CCUtility setPushNotificationSubscribingPublicKey:account publicKey:publicKey];
|
|
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationTokenWithAccount:account token:self.pushKitToken];
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationDeviceIdentifierWithAccount:account deviceIdentifier:deviceIdentifier];
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationDeviceIdentifierSignatureWithAccount:account deviceIdentifierSignature:signature];
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationSubscribingPublicKeyWithAccount:account publicKey:publicKey];
|
|
}
|
|
}
|
|
}];
|
|
}];
|
|
}
|
|
}
|
|
@@ -128,9 +128,9 @@
|
|
{
|
|
{
|
|
if (appDelegate.account == nil || appDelegate.account.length == 0) { return; }
|
|
if (appDelegate.account == nil || appDelegate.account.length == 0) { return; }
|
|
|
|
|
|
- NSString *deviceIdentifier = [CCUtility getPushNotificationDeviceIdentifier:account];
|
|
|
|
- NSString *signature = [CCUtility getPushNotificationDeviceIdentifierSignature:account];
|
|
|
|
- NSString *publicKey = [CCUtility getPushNotificationSubscribingPublicKey:account];
|
|
|
|
|
|
+ NSString *deviceIdentifier = [[[NCKeychain alloc] init] getPushNotificationDeviceIdentifierWithAccount:account];
|
|
|
|
+ NSString *signature = [[[NCKeychain alloc] init] getPushNotificationDeviceIdentifierSignatureWithAccount:account];
|
|
|
|
+ NSString *publicKey = [[[NCKeychain alloc] init] getPushNotificationSubscribingPublicKeyWithAccount:account];
|
|
|
|
|
|
[[NextcloudKit shared] unsubscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[[[NCKeychain alloc] init] getPasswordWithAccount:account] customUserAgent:nil addCustomHeaders:nil queue:dispatch_get_main_queue() completion:^(NSString *account, NKError *error) {
|
|
[[NextcloudKit shared] unsubscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[[[NCKeychain alloc] init] getPasswordWithAccount:account] customUserAgent:nil addCustomHeaders:nil queue:dispatch_get_main_queue() completion:^(NSString *account, NKError *error) {
|
|
if (error == NKError.success) {
|
|
if (error == NKError.success) {
|
|
@@ -141,13 +141,13 @@
|
|
|
|
|
|
[[[NextcloudKit shared] nkCommonInstance] writeLog:@"[INFO] Unsubscribed to Push Notification server & proxy successfully."];
|
|
[[[NextcloudKit shared] nkCommonInstance] writeLog:@"[INFO] Unsubscribed to Push Notification server & proxy successfully."];
|
|
|
|
|
|
- [CCUtility setPushNotificationPublicKey:account data:nil];
|
|
|
|
- [CCUtility setPushNotificationSubscribingPublicKey:account publicKey:nil];
|
|
|
|
- [CCUtility setPushNotificationPrivateKey:account data:nil];
|
|
|
|
- [CCUtility setPushNotificationToken:account token:nil];
|
|
|
|
- [CCUtility setPushNotificationDeviceIdentifier:account deviceIdentifier:nil];
|
|
|
|
- [CCUtility setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:nil];
|
|
|
|
-
|
|
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationPublicKeyWithAccount:account data:nil];
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationSubscribingPublicKeyWithAccount:account publicKey:nil];
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationPrivateKeyWithAccount:account data:nil];
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationTokenWithAccount:account token:nil];
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationDeviceIdentifierWithAccount:account deviceIdentifier:nil];
|
|
|
|
+ [[[NCKeychain alloc] init] setPushNotificationDeviceIdentifierSignatureWithAccount:account deviceIdentifierSignature:nil];
|
|
|
|
+
|
|
if (self.pushKitToken != nil && subscribing) {
|
|
if (self.pushKitToken != nil && subscribing) {
|
|
[self subscribingNextcloudServerPushNotification:account urlBase:urlBase user:user];
|
|
[self subscribingNextcloudServerPushNotification:account urlBase:urlBase user:user];
|
|
}
|
|
}
|