Skip to content

Commit

Permalink
Merge pull request #1522 from nextcloud/add-push-logging
Browse files Browse the repository at this point in the history
Add logging for push subscription error
  • Loading branch information
Ivansss committed Feb 6, 2024
2 parents b52901c + 2324011 commit 403f83d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions NextcloudTalk/NCKeyChainController.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern NSString * const kNCPushKitTokenKey;
- (void)setPushNotificationPrivateKey:(NSData *)privateKey forAccountId:(NSString *)accountId;
- (NSData *)pushNotificationPrivateKeyForAccountId:(NSString *)accountId;
- (NSString *)pushTokenSHA512;
- (void)logCombinedPushToken;
- (NSString *)combinedPushToken;
- (void)removeAllItems;

Expand Down
18 changes: 18 additions & 0 deletions NextcloudTalk/NCKeyChainController.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@ - (NSString *)pushTokenSHA512
return [self createSHA512:token];
}

- (void)logCombinedPushToken
{
NSString *normalPushToken = [_keychain stringForKey:kNCNormalPushTokenKey];
NSString *pushKitToken = [_keychain stringForKey:kNCPushKitTokenKey];

if (normalPushToken && [normalPushToken length] >= 10) {
[NCUtils log:[NSString stringWithFormat:@"Push notification, normal push token: %@... length %ld", [normalPushToken substringToIndex:10], [normalPushToken length]]];
} else {
[NCUtils log:@"Push notification, normal push token length < 10"];
}

if (pushKitToken && [pushKitToken length] >= 10) {
[NCUtils log:[NSString stringWithFormat:@"Push notification, pushKit token: %@... length %ld", [pushKitToken substringToIndex:10], [pushKitToken length]]];
} else {
[NCUtils log:@"Push notification, pushKit token length < 10"];
}
}

- (NSString *)combinedPushToken
{
NSString *normalPushToken = [_keychain stringForKey:kNCNormalPushTokenKey];
Expand Down
4 changes: 4 additions & 0 deletions NextcloudTalk/NCSettingsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,10 @@ - (void)subscribeForPushNotificationsForAccountId:(NSString *)accountId withComp
[bgTask stopBackgroundTask];
} else {
[NCUtils log:[NSString stringWithFormat:@"Error while subscribing to Push Notification server. Error: %@", error.description]];
[NCUtils log:[NSString stringWithFormat:@"Push notification, public key: %@", publicKey]];
[NCUtils log:[NSString stringWithFormat:@"Push notification, device signature: %@", signature]];
[NCUtils log:[NSString stringWithFormat:@"Push notification, device identifier: %@", deviceIdentifier]];
[[NCKeyChainController sharedInstance] logCombinedPushToken];

if (block) {
block(NO);
Expand Down

0 comments on commit 403f83d

Please sign in to comment.