mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Show push tokens in about view.
// FREEBIE
This commit is contained in:
parent
9b14c77775
commit
6e60d99ecf
|
@ -8,6 +8,8 @@ import PromiseKit
|
|||
class SyncPushTokensJob: NSObject {
|
||||
let TAG = "[SyncPushTokensJob]"
|
||||
|
||||
@objc public static let PushTokensDidChange = Notification.Name("PushTokensDidChange")
|
||||
|
||||
// MARK: Dependencies
|
||||
let accountManager: AccountManager
|
||||
let preferences: OWSPreferences
|
||||
|
@ -90,14 +92,24 @@ class SyncPushTokensJob: NSObject {
|
|||
private func recordPushTokensLocally(pushToken: String, voipToken: String) -> Promise<Void> {
|
||||
Logger.warn("\(TAG) Recording push tokens locally. pushToken: \(pushToken), voipToken: \(voipToken)")
|
||||
|
||||
var didTokensChange = false
|
||||
|
||||
if (pushToken != self.preferences.getPushToken()) {
|
||||
Logger.info("\(TAG) Recording new plain push token")
|
||||
self.preferences.setPushToken(pushToken)
|
||||
didTokensChange = true
|
||||
}
|
||||
|
||||
if (voipToken != self.preferences.getVoipToken()) {
|
||||
Logger.info("\(TAG) Recording new voip token")
|
||||
self.preferences.setVoipToken(voipToken)
|
||||
didTokensChange = true
|
||||
}
|
||||
|
||||
if (didTokensChange) {
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: SyncPushTokensJob.PushTokensDidChange, object: nil)
|
||||
}
|
||||
}
|
||||
|
||||
return Promise(value: ())
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
//
|
||||
|
||||
#import "AboutTableViewController.h"
|
||||
#import "Environment.h"
|
||||
#import "OWSPreferences.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import "UIUtil.h"
|
||||
#import "UIView+OWS.h"
|
||||
#import <SignalServiceKit/TSDatabaseView.h>
|
||||
|
@ -10,6 +13,10 @@
|
|||
|
||||
@implementation AboutTableViewController
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
@ -17,6 +24,15 @@
|
|||
self.title = NSLocalizedString(@"SETTINGS_ABOUT", @"Navbar title");
|
||||
|
||||
[self updateTableContents];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(pushTokensDidChange:)
|
||||
name:[OWSSyncPushTokensJob PushTokensDidChange]
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)pushTokensDidChange:(NSNotification *)notification {
|
||||
[self updateTableContents];
|
||||
}
|
||||
|
||||
#pragma mark - Table Contents
|
||||
|
@ -64,6 +80,12 @@
|
|||
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Threads: %zd", threadCount]]];
|
||||
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Messages: %zd", messageCount]]];
|
||||
[contents addSection:debugSection];
|
||||
|
||||
OWSPreferences *preferences = [Environment preferences];
|
||||
NSString *_Nullable pushToken = [preferences getPushToken];
|
||||
NSString *_Nullable voipToken = [preferences getVoipToken];
|
||||
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Push Token: %@", pushToken ?: @"None" ]]];
|
||||
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"VOIP Token: %@", voipToken ?: @"None" ]]];
|
||||
#endif
|
||||
|
||||
self.contents = contents;
|
||||
|
|
Loading…
Reference in a new issue