Save push token in the keychain.

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2017-11-07 16:59:19 +01:00
Родитель d316c027d6
Коммит 5c7d2c738a
3 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -16,7 +16,7 @@
#import <WebRTC/RTCAudioSession.h>
#import <WebRTC/RTCAudioSessionConfiguration.h>
#import "UICKeyChainStore.h"
#import "NCSettingsController.h"
@interface AppDelegate () <UNUserNotificationCenterDelegate, FIRMessagingDelegate>
@ -100,6 +100,7 @@
- (void)messaging:(FIRMessaging *)messaging didRefreshRegistrationToken:(NSString *)fcmToken
{
NSLog(@"FCM registration token: %@", fcmToken);
[NCSettingsController sharedInstance].ncPushToken = fcmToken;
}

Просмотреть файл

@ -15,6 +15,7 @@ extern NSString * const kNCServerKey;
extern NSString * const kNCUserKey;
extern NSString * const kNCUserDisplayNameKey;
extern NSString * const kNCTokenKey;
extern NSString * const kNCPushTokenKey;
@interface NCSettingsController : NSObject
@ -23,6 +24,7 @@ extern NSString * const kNCTokenKey;
@property (nonatomic, copy) NSString *ncUser;
@property (nonatomic, copy) NSString *ncUserDisplayName;
@property (nonatomic, copy) NSString *ncToken;
@property (nonatomic, copy) NSString *ncPushToken;
+ (instancetype)sharedInstance;
- (void)cleanAllStoredValues;

Просмотреть файл

@ -16,6 +16,7 @@ NSString * const kNCServerKey = @"ncServer";
NSString * const kNCUserKey = @"ncUser";
NSString * const kNCUserDisplayNameKey = @"ncUserDisplayName";
NSString * const kNCTokenKey = @"ncToken";
NSString * const kNCPushTokenKey = @"ncPushToken";
+ (NCSettingsController *)sharedInstance
{
@ -42,6 +43,7 @@ NSString * const kNCTokenKey = @"ncToken";
_ncUser = [UICKeyChainStore stringForKey:kNCUserKey];
_ncUserDisplayName = [UICKeyChainStore stringForKey:kNCUserDisplayNameKey];
_ncToken = [UICKeyChainStore stringForKey:kNCTokenKey];
_ncPushToken = [UICKeyChainStore stringForKey:kNCPushTokenKey];
}
- (void)cleanAllStoredValues
@ -50,6 +52,7 @@ NSString * const kNCTokenKey = @"ncToken";
_ncUser = nil;
_ncUserDisplayName = nil;
_ncToken = nil;
_ncPushToken = nil;
[UICKeyChainStore removeAllItems];