diff --git a/Source/ARTPushChannel.m b/Source/ARTPushChannel.m index 57c8207d3..f52b4bb2a 100644 --- a/Source/ARTPushChannel.m +++ b/Source/ARTPushChannel.m @@ -24,41 +24,41 @@ - (instancetype)initWithInternal:(ARTPushChannelInternal *)internal queuedDeallo } - (void)subscribeDevice { - [_internal subscribeDevice]; + [_internal subscribeDeviceWithWrapperSDKAgents:nil]; } - (void)subscribeDevice:(ARTCallback)callback { - [_internal subscribeDevice:callback]; + [_internal subscribeDeviceWithWrapperSDKAgents:nil completion:callback]; } - (void)subscribeClient { - [_internal subscribeClient]; + [_internal subscribeClientWithWrapperSDKAgents:nil]; } - (void)subscribeClient:(ARTCallback)callback { - [_internal subscribeClient:callback]; + [_internal subscribeClientWithWrapperSDKAgents:nil completion:callback]; } - (void)unsubscribeDevice { - [_internal unsubscribeDevice]; + [_internal unsubscribeDeviceWithWrapperSDKAgents:nil]; } - (void)unsubscribeDevice:(ARTCallback)callback { - [_internal unsubscribeDevice:callback]; + [_internal unsubscribeDeviceWithWrapperSDKAgents:nil completion:callback]; } - (void)unsubscribeClient { - [_internal unsubscribeClient]; + [_internal unsubscribeClientWithWrapperSDKAgents:nil]; } - (void)unsubscribeClient:(ARTCallback)callback { - [_internal unsubscribeClient:callback]; + [_internal unsubscribeClientWithWrapperSDKAgents:nil completion:callback]; } - (BOOL)listSubscriptions:(NSStringDictionary *)params callback:(ARTPaginatedPushChannelCallback)callback error:(NSError *_Nullable *_Nullable)errorPtr { - return [_internal listSubscriptions:params callback:callback error:errorPtr]; + return [_internal listSubscriptions:params wrapperSDKAgents:nil callback:callback error:errorPtr]; } @end @@ -86,23 +86,23 @@ - (instancetype)init:(ARTRestInternal *)rest withChannel:(ARTChannel *)channel l return self; } -- (void)subscribeDevice { - [self subscribeDevice:nil]; +- (void)subscribeDeviceWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents { + [self subscribeDeviceWithWrapperSDKAgents:wrapperSDKAgents completion:nil]; } -- (void)unsubscribeDevice { - [self unsubscribeDevice:nil]; +- (void)unsubscribeDeviceWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents { + [self unsubscribeDeviceWithWrapperSDKAgents:wrapperSDKAgents completion:nil]; } -- (void)subscribeClient { - [self subscribeClient:nil]; +- (void)subscribeClientWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents { + [self subscribeClientWithWrapperSDKAgents:wrapperSDKAgents completion:nil]; } -- (void)unsubscribeClient { - [self unsubscribeClient:nil]; +- (void)unsubscribeClientWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents { + [self unsubscribeClientWithWrapperSDKAgents:wrapperSDKAgents completion:nil]; } -- (void)subscribeDevice:(ARTCallback)callback { +- (void)subscribeDeviceWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents completion:(ARTCallback)callback { if (callback) { ARTCallback userCallback = callback; callback = ^(ARTErrorInfo *_Nullable error) { @@ -129,7 +129,7 @@ - (void)subscribeDevice:(ARTCallback)callback { [request setDeviceAuthentication:deviceId localDevice:device]; ARTLogDebug(self->_logger, @"subscribe notifications for device %@ in channel %@", deviceId, self->_channel.name); - [self->_rest executeRequest:request withAuthOption:ARTAuthenticationOn wrapperSDKAgents:nil completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { + [self->_rest executeRequest:request withAuthOption:ARTAuthenticationOn wrapperSDKAgents:wrapperSDKAgents completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { if (error) { ARTLogError(self->_logger, @"%@: subscribe notifications for device %@ in channel %@ failed (%@)", NSStringFromClass(self.class), deviceId, self->_channel.name, error.localizedDescription); } @@ -138,7 +138,7 @@ - (void)subscribeDevice:(ARTCallback)callback { }); } -- (void)subscribeClient:(ARTCallback)callback { +- (void)subscribeClientWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents completion:(ARTCallback)callback { if (callback) { ARTCallback userCallback = callback; callback = ^(ARTErrorInfo *_Nullable error) { @@ -163,7 +163,7 @@ - (void)subscribeClient:(ARTCallback)callback { [request setValue:[[self->_rest defaultEncoder] mimeType] forHTTPHeaderField:@"Content-Type"]; ARTLogDebug(self->_logger, @"subscribe notifications for clientId %@ in channel %@", clientId, self->_channel.name); - [self->_rest executeRequest:request withAuthOption:ARTAuthenticationOn wrapperSDKAgents:nil completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { + [self->_rest executeRequest:request withAuthOption:ARTAuthenticationOn wrapperSDKAgents:wrapperSDKAgents completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { if (error) { ARTLogError(self->_logger, @"%@: subscribe notifications for clientId %@ in channel %@ failed (%@)", NSStringFromClass(self.class), clientId, self->_channel.name, error.localizedDescription); } @@ -172,7 +172,7 @@ - (void)subscribeClient:(ARTCallback)callback { }); } -- (void)unsubscribeDevice:(ARTCallback)callback { +- (void)unsubscribeDeviceWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents completion:(ARTCallback)callback { if (callback) { ARTCallback userCallback = callback; callback = ^(ARTErrorInfo *_Nullable error) { @@ -200,7 +200,7 @@ - (void)unsubscribeDevice:(ARTCallback)callback { [request setDeviceAuthentication:deviceId localDevice:device]; ARTLogDebug(self->_logger, @"unsubscribe notifications for device %@ in channel %@", deviceId, self->_channel.name); - [self->_rest executeRequest:request withAuthOption:ARTAuthenticationOn wrapperSDKAgents:nil completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { + [self->_rest executeRequest:request withAuthOption:ARTAuthenticationOn wrapperSDKAgents:wrapperSDKAgents completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { if (error) { ARTLogError(self->_logger, @"%@: unsubscribe notifications for device %@ in channel %@ failed (%@)", NSStringFromClass(self.class), deviceId, self->_channel.name, error.localizedDescription); } @@ -209,7 +209,7 @@ - (void)unsubscribeDevice:(ARTCallback)callback { }); } -- (void)unsubscribeClient:(ARTCallback)callback { +- (void)unsubscribeClientWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents completion:(ARTCallback)callback { if (callback) { ARTCallback userCallback = callback; callback = ^(ARTErrorInfo *_Nullable error) { @@ -235,7 +235,7 @@ - (void)unsubscribeClient:(ARTCallback)callback { request.HTTPMethod = @"DELETE"; ARTLogDebug(self->_logger, @"unsubscribe notifications for clientId %@ in channel %@", clientId, self->_channel.name); - [self->_rest executeRequest:request withAuthOption:ARTAuthenticationOn wrapperSDKAgents:nil completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { + [self->_rest executeRequest:request withAuthOption:ARTAuthenticationOn wrapperSDKAgents:wrapperSDKAgents completion:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { if (error) { ARTLogError(self->_logger, @"%@: unsubscribe notifications for clientId %@ in channel %@ failed (%@)", NSStringFromClass(self.class), clientId, self->_channel.name, error.localizedDescription); } @@ -245,6 +245,7 @@ - (void)unsubscribeClient:(ARTCallback)callback { } - (BOOL)listSubscriptions:(NSStringDictionary *)params + wrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents callback:(ARTPaginatedPushChannelCallback)callback error:(NSError * __autoreleasing *)errorPtr { if (callback) { @@ -290,7 +291,7 @@ - (BOOL)listSubscriptions:(NSStringDictionary *)params return [self->_rest.encoders[response.MIMEType] decodePushChannelSubscriptions:data error:error]; }; - [ARTPaginatedResult executePaginated:self->_rest withRequest:request andResponseProcessor:responseProcessor wrapperSDKAgents:nil logger:self->_logger callback:callback]; + [ARTPaginatedResult executePaginated:self->_rest withRequest:request andResponseProcessor:responseProcessor wrapperSDKAgents:wrapperSDKAgents logger:self->_logger callback:callback]; ret = YES; }); return ret; diff --git a/Source/ARTWrapperSDKProxyPushChannel.m b/Source/ARTWrapperSDKProxyPushChannel.m index 216a58308..f4ae3c526 100644 --- a/Source/ARTWrapperSDKProxyPushChannel.m +++ b/Source/ARTWrapperSDKProxyPushChannel.m @@ -1,4 +1,6 @@ #import "ARTWrapperSDKProxyPushChannel+Private.h" +#import "ARTPushChannel+Private.h" +#import "ARTWrapperSDKProxyOptions.h" NS_ASSUME_NONNULL_BEGIN @@ -27,35 +29,39 @@ - (BOOL)listSubscriptions:(nonnull NSStringDictionary *)params callback:(nonnull } - (void)subscribeClient { - [self.underlyingPushChannel subscribeClient]; + [self.underlyingPushChannel.internal subscribeClientWithWrapperSDKAgents:self.proxyOptions.agents]; } - (void)subscribeClient:(nullable ARTCallback)callback { - [self.underlyingPushChannel subscribeClient:callback]; + [self.underlyingPushChannel.internal subscribeClientWithWrapperSDKAgents:self.proxyOptions.agents + completion:callback]; } - (void)subscribeDevice { - [self.underlyingPushChannel subscribeDevice]; + [self.underlyingPushChannel.internal subscribeDeviceWithWrapperSDKAgents:self.proxyOptions.agents]; } - (void)subscribeDevice:(nullable ARTCallback)callback { - [self.underlyingPushChannel subscribeDevice:callback]; + [self.underlyingPushChannel.internal subscribeDeviceWithWrapperSDKAgents:self.proxyOptions.agents + completion:callback]; } - (void)unsubscribeClient { - [self.underlyingPushChannel unsubscribeClient]; + [self.underlyingPushChannel.internal unsubscribeClientWithWrapperSDKAgents:self.proxyOptions.agents]; } - (void)unsubscribeClient:(nullable ARTCallback)callback { - [self.underlyingPushChannel unsubscribeClient:callback]; + [self.underlyingPushChannel.internal unsubscribeClientWithWrapperSDKAgents:self.proxyOptions.agents + completion:callback]; } - (void)unsubscribeDevice { - [self.underlyingPushChannel unsubscribeDevice]; + [self.underlyingPushChannel.internal unsubscribeDeviceWithWrapperSDKAgents:self.proxyOptions.agents]; } - (void)unsubscribeDevice:(nullable ARTCallback)callback { - [self.underlyingPushChannel unsubscribeDevice:callback]; + [self.underlyingPushChannel.internal unsubscribeDeviceWithWrapperSDKAgents:self.proxyOptions.agents + completion:callback]; } @end diff --git a/Source/PrivateHeaders/Ably/ARTPushChannel+Private.h b/Source/PrivateHeaders/Ably/ARTPushChannel+Private.h index 77e1d39c2..3749c5dac 100644 --- a/Source/PrivateHeaders/Ably/ARTPushChannel+Private.h +++ b/Source/PrivateHeaders/Ably/ARTPushChannel+Private.h @@ -11,23 +11,28 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init:(ARTRestInternal *)rest withChannel:(ARTChannel *)channel logger:(ARTInternalLog *)logger; -- (void)subscribeDevice; +- (void)subscribeDeviceWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents; -- (void)subscribeDevice:(nullable ARTCallback)callback; +- (void)subscribeDeviceWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents + completion:(nullable ARTCallback)callback; -- (void)subscribeClient; +- (void)subscribeClientWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents; -- (void)subscribeClient:(nullable ARTCallback)callback; +- (void)subscribeClientWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents + completion:(nullable ARTCallback)callback; -- (void)unsubscribeDevice; +- (void)unsubscribeDeviceWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents; -- (void)unsubscribeDevice:(nullable ARTCallback)callback; +- (void)unsubscribeDeviceWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents + completion:(nullable ARTCallback)callback; -- (void)unsubscribeClient; +- (void)unsubscribeClientWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents; -- (void)unsubscribeClient:(nullable ARTCallback)callback; +- (void)unsubscribeClientWithWrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents + completion:(nullable ARTCallback)callback; - (BOOL)listSubscriptions:(NSStringDictionary *)params + wrapperSDKAgents:(nullable NSStringDictionary *)wrapperSDKAgents callback:(ARTPaginatedPushChannelCallback)callback error:(NSError *_Nullable *_Nullable)errorPtr;