2015-12-07 03:31:43 +01:00
|
|
|
//
|
2017-04-01 00:45:46 +02:00
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
2015-12-07 03:31:43 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "TSConstants.h"
|
|
|
|
|
2016-11-03 21:10:06 +01:00
|
|
|
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;
|
2017-05-10 22:00:36 +02:00
|
|
|
extern NSString *const kNSNotificationName_LocalNumberDidChange;
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2016-11-03 21:10:06 +01:00
|
|
|
@class TSNetworkManager;
|
|
|
|
@class TSStorageManager;
|
2015-12-07 03:31:43 +01:00
|
|
|
|
|
|
|
@interface TSAccountManager : NSObject
|
|
|
|
|
2016-12-18 22:08:26 +01:00
|
|
|
#pragma mark - Initializers
|
|
|
|
|
2017-04-01 00:45:46 +02:00
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
|
2016-11-03 21:10:06 +01:00
|
|
|
- (instancetype)initWithNetworkManager:(TSNetworkManager *)networkManager
|
2017-08-02 21:15:31 +02:00
|
|
|
storageManager:(TSStorageManager *)storageManager NS_DESIGNATED_INITIALIZER;
|
2016-11-03 21:10:06 +01:00
|
|
|
|
|
|
|
+ (instancetype)sharedInstance;
|
|
|
|
|
2016-12-18 22:08:26 +01:00
|
|
|
@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;
|
2016-11-03 21:10:06 +01:00
|
|
|
|
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
|
|
|
|
*/
|
2016-11-03 21:10:06 +01:00
|
|
|
+ (nullable NSString *)localNumber;
|
2017-08-02 21:15:31 +02:00
|
|
|
- (nullable NSString *)localNumber;
|
2015-12-07 03:31:43 +01:00
|
|
|
|
2017-10-10 21:06:45 +02: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
|
2016-11-03 21:10:06 +01:00
|
|
|
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
|
|
|
|
2016-11-03 21:10:06 +01:00
|
|
|
- (void)verifyAccountWithCode:(NSString *)verificationCode
|
2017-11-08 20:04:51 +01:00
|
|
|
success:(void (^)(void))successBlock
|
2016-11-03 21:10:06 +01:00
|
|
|
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
|
2017-10-11 16:23:24 +02:00
|
|
|
failure:(void (^)(NSError *error))failureBlock;
|
|
|
|
|
Rework push registration
== Account Registration ==
Not complete until push tokens are uploaded
== Remote Notifications Registration ==
Extracted from PushManager
- wait for notification-settings registration to complete before
requesting push tokens, otherwise it's possible token requests will
be ignored.
- Less state required for push notification callbacks, specifically, we
no longer need to ensure we've created a promise before the
registration delegate methods get called.
- no more TOCFuture in Signal-iOS (still in SSK for now). It's not in
cases of inexplicable behavior - one a recently, push notification
premature free, in redphone, and more popular use, and I've seen two
futures inexplicably being nil. Instead, let's consolidate around
PromiseKit for popularly used, maintained, strongly-typed futures.
- separate logic for registering for vanilla push/voip notifications
(few dependencies) from responding to UILocalNotifications (lots of
dependencies). Ultimately I'd like to consolidate the remaining
UILocalNotifications logic with the existing NotificationsManager
== Misc ==
more debug logging
more uniform logging
remove stale logic around newly registered user
// FREEBIE
2017-09-20 23:47:12 +02:00
|
|
|
// 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
|
|
|
|
*/
|
2016-11-03 21:10:06 +01:00
|
|
|
- (void)registerForPushNotificationsWithPushToken:(NSString *)pushToken
|
|
|
|
voipToken:(NSString *)voipToken
|
2017-11-08 20:04:51 +01:00
|
|
|
success:(void (^)(void))successHandler
|
2016-11-03 21:10:06 +01:00
|
|
|
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
|
2016-11-03 21:10:06 +01:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|