Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper RSH8b and RSH3g2a behavior. #1847

Merged
merged 17 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions Source/ARTLocalDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ - (BOOL)setupDetailsWithClientId:(NSString *)clientId {
return YES;
}

- (void)resetDetails {
self.id = @"";
self.secret = nil;
self.clientId = nil;
[_storage setObject:nil forKey:ARTDeviceIdKey];
[self setAndPersistIdentityTokenDetails:nil];
NSArray *supportedTokenTypes = @[
ARTAPNSDeviceDefaultTokenType,
ARTAPNSDeviceLocationTokenType
];
for (NSString *tokenType in supportedTokenTypes) {
[self setAndPersistAPNSDeviceToken:nil tokenType:tokenType];
}
}

+ (NSString *)generateId {
return [NSUUID new].UUIDString;
}
Expand Down Expand Up @@ -173,9 +188,4 @@ - (BOOL)isRegistered {
return _identityTokenDetails != nil;
}

- (void)clearIdentityTokenDetailsAndClientId {
[self setAndPersistIdentityTokenDetails:nil];
self.clientId = nil;
}

@end
3 changes: 1 addition & 2 deletions Source/ARTPushActivationState.m
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ - (ARTPushActivationState *)transition:(ARTPushActivationEvent *)event {
}
else if ([event isKindOfClass:[ARTPushActivationEventDeregistered class]]) {
#if TARGET_OS_IOS
ARTLocalDevice *local = self.machine.rest.device_nosync;
[local clearIdentityTokenDetailsAndClientId];
[self.machine.rest resetLocalDevice];
#endif
[self.machine callDeactivatedCallback:nil];
return [ARTPushActivationStateNotActivated newWithMachine:self.machine logger:self.logger];
Expand Down
7 changes: 7 additions & 0 deletions Source/ARTRest.m
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,13 @@ - (void)setupLocalDevice {
});
}

- (void)resetLocalDevice {
lawrence-forooghian marked this conversation as resolved.
Show resolved Hide resolved
ARTLocalDevice *device = [self device_nosync];
dispatch_sync([ARTRestInternal deviceAccessQueue], ^{
[device resetDetails];
});
}

- (void)resetDeviceSingleton {
dispatch_sync([ARTRestInternal deviceAccessQueue], ^{
sharedDeviceNeedsLoading_onlyAccessOnDeviceAccessQueue = YES;
Expand Down
2 changes: 1 addition & 1 deletion Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ NSString* ARTAPNSDeviceTokenKeyOfType(NSString * _Nullable tokenType);
- (void)setAndPersistAPNSDeviceToken:(nullable NSString *)deviceToken;
- (void)setAndPersistIdentityTokenDetails:(nullable ARTDeviceIdentityTokenDetails *)tokenDetails;
- (BOOL)isRegistered;
- (void)clearIdentityTokenDetailsAndClientId;
- (void)resetDetails;
- (BOOL)setupDetailsWithClientId:(nullable NSString *)clientId;

+ (NSString *)generateId;
Expand Down
2 changes: 2 additions & 0 deletions Source/PrivateHeaders/Ably/ARTRest+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ NS_ASSUME_NONNULL_BEGIN

#if TARGET_OS_IOS
- (void)setupLocalDevice;
- (void)resetLocalDevice;

// This is only intended to be called from test code.
- (void)resetDeviceSingleton;

Expand Down