session-ios/SignalServiceKit/src/Account/TSAccountManager.h

113 lines
3.4 KiB
C
Raw Normal View History

2015-12-07 03:31:43 +01:00
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
2015-12-07 03:31:43 +01:00
//
#import "TSConstants.h"
NS_ASSUME_NONNULL_BEGIN
2017-04-08 03:28:34 +02:00
extern NSString *const TSRegistrationErrorDomain;
extern NSString *const TSRegistrationErrorUserInfoHTTPStatus;
extern NSString *const kNSNotificationName_RegistrationStateDidChange;
extern NSString *const kNSNotificationName_LocalNumberDidChange;
2015-12-07 03:31:43 +01:00
@class TSNetworkManager;
@class TSStorageManager;
2015-12-07 03:31:43 +01:00
@interface TSAccountManager : NSObject
#pragma mark - Initializers
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithNetworkManager:(TSNetworkManager *)networkManager
storageManager:(TSStorageManager *)storageManager NS_DESIGNATED_INITIALIZER;
+ (instancetype)sharedInstance;
@property (nonatomic, strong, readonly) TSNetworkManager *networkManager;
2015-12-07 03:31:43 +01:00
/**
* Returns if a user is registered or not
*
* @return registered or not
*/
+ (BOOL)isRegistered;
2015-12-07 03:31:43 +01:00
/**
2017-01-03 22:32:53 +01:00
* Returns current phone number for this device, which may not yet have been registered.
2015-12-07 03:31:43 +01:00
*
* @return E164 formatted phone number
*/
+ (nullable NSString *)localNumber;
- (nullable NSString *)localNumber;
2015-12-07 03:31:43 +01:00
/**
* Symmetric key that's used to encrypt message payloads from the server,
*
* @return signaling key
*/
+ (nullable NSString *)signalingKey;
- (nullable NSString *)signalingKey;
/**
* The server auth token allows the Signal client to connect to the Signal server
*
* @return server authentication token
*/
+ (nullable NSString *)serverAuthToken;
- (nullable NSString *)serverAuthToken;
2015-12-07 03:31:43 +01:00
/**
* The registration ID is unique to an installation of TextSecure, it allows to know if the app was reinstalled
*
* @return registrationID;
*/
+ (uint32_t)getOrGenerateRegistrationId;
#pragma mark - Register with phone number
+ (void)registerWithPhoneNumber:(NSString *)phoneNumber
2017-11-08 20:04:51 +01:00
success:(void (^)(void))successBlock
failure:(void (^)(NSError *error))failureBlock
2015-12-07 03:31:43 +01:00
smsVerification:(BOOL)isSMS;
2017-11-08 20:04:51 +01:00
+ (void)rerequestSMSWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock;
2015-12-07 03:31:43 +01:00
2017-11-08 20:04:51 +01:00
+ (void)rerequestVoiceWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock;
2015-12-07 03:31:43 +01:00
- (void)verifyAccountWithCode:(NSString *)verificationCode
2017-11-08 20:04:51 +01:00
success:(void (^)(void))successBlock
failure:(void (^)(NSError *error))failureBlock;
2015-12-07 03:31:43 +01:00
2017-11-08 20:04:51 +01:00
- (void)registerForManualMessageFetchingWithSuccess:(void (^)(void))successBlock
failure:(void (^)(NSError *error))failureBlock;
// Called once registration is complete - meaning the following have succeeded:
// - obtained signal server credentials
// - uploaded pre-keys
// - uploaded push tokens
- (void)didRegister;
2015-12-07 03:31:43 +01:00
#if TARGET_OS_IPHONE
/**
* Register's the device's push notification token with the server
*
* @param pushToken Apple's Push Token
*/
- (void)registerForPushNotificationsWithPushToken:(NSString *)pushToken
voipToken:(NSString *)voipToken
2017-11-08 20:04:51 +01:00
success:(void (^)(void))successHandler
failure:(void (^)(NSError *error))failureHandler
2017-11-08 20:25:21 +01:00
NS_SWIFT_NAME(registerForPushNotifications(pushToken:voipToken:success:failure:));
2015-12-07 03:31:43 +01:00
#endif
2017-11-08 20:04:51 +01:00
+ (void)unregisterTextSecureWithSuccess:(void (^)(void))success failure:(void (^)(NSError *error))failureBlock;
2015-12-07 03:31:43 +01:00
@end
NS_ASSUME_NONNULL_END