diff --git a/Ably.xcodeproj/project.pbxproj b/Ably.xcodeproj/project.pbxproj index 83b9d451d..d0aec78ec 100644 --- a/Ably.xcodeproj/project.pbxproj +++ b/Ably.xcodeproj/project.pbxproj @@ -284,12 +284,21 @@ 80E519C72BBCBE21006545B4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */; }; 80E519C82BBCBE21006545B4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */; }; 80E519C92BBCBE21006545B4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */; }; + 84039A4C2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 84039A4D2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 84039A4E2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 840FCE532C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 840FCE542C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 840FCE552C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 841134782722205400CFA837 /* ARTArchiveTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 841134772722205400CFA837 /* ARTArchiveTests.m */; }; 8412FDE72661AC37001FE9E6 /* AblyDeltaCodec.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDE12661AC37001FE9E6 /* AblyDeltaCodec.xcframework */; }; 8412FDED2661AC37001FE9E6 /* msgpack.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDE32661AC37001FE9E6 /* msgpack.xcframework */; }; 8412FDFE2661AC7B001FE9E6 /* Nimble.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDF42661AC7B001FE9E6 /* Nimble.xcframework */; }; 8412FDFF2661AC7B001FE9E6 /* Nimble.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDF42661AC7B001FE9E6 /* Nimble.xcframework */; }; 8412FE002661AC7B001FE9E6 /* Nimble.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8412FDF42661AC7B001FE9E6 /* Nimble.xcframework */; }; + 844B9CCF2C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 844B9CD02C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 844B9CD12C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 848ED97326E50D0F0087E800 /* ObjcppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 848ED97226E50D0F0087E800 /* ObjcppTest.mm */; settings = {COMPILER_FLAGS = "-fmodules"; }; }; 848ED97426E50D0F0087E800 /* ObjcppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 848ED97226E50D0F0087E800 /* ObjcppTest.mm */; settings = {COMPILER_FLAGS = "-fmodules"; }; }; 848ED97526E50D0F0087E800 /* ObjcppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 848ED97226E50D0F0087E800 /* ObjcppTest.mm */; settings = {COMPILER_FLAGS = "-fmodules"; }; }; @@ -1229,10 +1238,13 @@ 560579D824AF1BA900A4D03D /* ARTDefaultTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ARTDefaultTests.swift; sourceTree = ""; }; 56190953238C3D3200A862A6 /* CryptoTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CryptoTest.m; sourceTree = ""; }; 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ARTChannelOptions+Private.h"; path = "PrivateHeaders/Ably/ARTChannelOptions+Private.h"; sourceTree = ""; }; + 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ARTDevicePushDetails+Private.h"; path = "PrivateHeaders/Ably/ARTDevicePushDetails+Private.h"; sourceTree = ""; }; 841134772722205400CFA837 /* ARTArchiveTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTArchiveTests.m; sourceTree = ""; }; 8412FDE12661AC37001FE9E6 /* AblyDeltaCodec.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = AblyDeltaCodec.xcframework; path = Carthage/Build/AblyDeltaCodec.xcframework; sourceTree = ""; }; 8412FDE32661AC37001FE9E6 /* msgpack.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = msgpack.xcframework; path = Carthage/Build/msgpack.xcframework; sourceTree = ""; }; 8412FDF42661AC7B001FE9E6 /* Nimble.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Nimble.xcframework; path = Carthage/Build/Nimble.xcframework; sourceTree = ""; }; + 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ARTDeviceDetails+Private.h"; path = "PrivateHeaders/Ably/ARTDeviceDetails+Private.h"; sourceTree = ""; }; 848ED97226E50D0F0087E800 /* ObjcppTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ObjcppTest.mm; sourceTree = ""; }; 850BFB4A1B79323C009D0ADD /* ARTPaginatedResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARTPaginatedResult.h; path = include/Ably/ARTPaginatedResult.h; sourceTree = ""; }; 850BFB4B1B79323C009D0ADD /* ARTPaginatedResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTPaginatedResult.m; sourceTree = ""; }; @@ -1999,6 +2011,7 @@ D746AE551BBD8622003ECEF8 /* ARTChannels+Private.h */, D746AE521BBD85C5003ECEF8 /* ARTChannels.m */, D746AE4D1BBD84E7003ECEF8 /* ARTChannelOptions.h */, + 84039A4B2C811F49001C053E /* ARTChannelOptions+Private.h */, D746AE4E1BBD84E7003ECEF8 /* ARTChannelOptions.m */, 96E408411A38939E00087F77 /* ARTProtocolMessage.h */, D77394021C6F6FFE00F5478F /* ARTProtocolMessage+Private.h */, @@ -2150,8 +2163,10 @@ D785C4271E549E33008FEC05 /* ARTPushChannelSubscription.h */, D785C4281E549E33008FEC05 /* ARTPushChannelSubscription.m */, D7B621921E4A6FE600684474 /* ARTDeviceDetails.h */, + 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */, D7B621931E4A6FE600684474 /* ARTDeviceDetails.m */, D768C6AA1E4B5B0200436011 /* ARTDevicePushDetails.h */, + 840FCE522C875B8A001163E1 /* ARTDevicePushDetails+Private.h */, D768C6AB1E4B5B0200436011 /* ARTDevicePushDetails.m */, D777EEDE206285CF002EBA03 /* ARTDeviceIdentityTokenDetails.h */, 2124B7A229DB153500AD8361 /* ARTDeviceIdentityTokenDetails+Private.h */, @@ -2233,6 +2248,7 @@ EB2D84F71CD75CCE00F23CDA /* ARTReachability.h in Headers */, D73B655523EF2B2900D459A6 /* ARTDeltaCodec.h in Headers */, 1C1EC3FA1AE26A8B00AAADD7 /* ARTStatus.h in Headers */, + 840FCE532C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */, D70EAAED1BC3376200CD8B9E /* ARTRestChannel.h in Headers */, 96BF61581A35B52C004CF2B3 /* ARTHttp.h in Headers */, 96BF61641A35CDE1004CF2B3 /* ARTBaseMessage.h in Headers */, @@ -2263,6 +2279,7 @@ 2105ED2229E7429E00DE6D67 /* ARTPaginatedResult+Subclass.h in Headers */, D746AE381BBC3201003ECEF8 /* ARTMessage.h in Headers */, D746AE471BBD6FE9003ECEF8 /* ARTQueuedMessage.h in Headers */, + 844B9CCF2C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */, D798556023ECCDAF00946BE2 /* ARTVCDiffDecoder.h in Headers */, EB9C530B1CD7BEB100.8.557 /* ARTJsonLikeEncoder.h in Headers */, D74CBC0E212F076000D090E4 /* ARTConstants.h in Headers */, @@ -2362,6 +2379,7 @@ D7D8F82B1BC2C706009718F2 /* ARTTokenRequest.h in Headers */, 2147F02D29E583AD0071CB94 /* ARTInternalLogCore.h in Headers */, D5BB211126AA993E00AA5F3E /* ARTNSURL+ARTUtils.h in Headers */, + 84039A4C2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */, EB1AE0CC1C5C1EB200D62250 /* ARTEventEmitter+Private.h in Headers */, 215F75F82922B1DB009E0E76 /* ARTClientInformation.h in Headers */, D7DF738A1EA645300013CD36 /* ARTLocalDeviceStorage.h in Headers */, @@ -2440,6 +2458,7 @@ D710D4C221949B9C008F54AD /* ARTRealtimeTransport.h in Headers */, D710D58121949D28008F54AD /* ARTTokenRequest.h in Headers */, D710D68421949ECE008F54AD /* ARTNSDictionary+ARTDictionaryUtil.h in Headers */, + 844B9CD02C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */, D5BB212F26AAA55C00AA5F3E /* ARTNSMutableURLRequest+ARTUtils.h in Headers */, D710D50821949C18008F54AD /* ARTRealtimePresence+Private.h in Headers */, D710D4A821949ADF008F54AD /* ARTRestPresence.h in Headers */, @@ -2464,12 +2483,14 @@ 211A610429DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */, D7D06F1026330E2800DEBDAD /* ARTHttp+Private.h in Headers */, 210F67A329E9D718007B9345 /* ARTRealtimeTransportFactory.h in Headers */, + 84039A4D2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */, EB1B541A22FB1D7F006A59AC /* ARTPushChannelSubscriptions+Private.h in Headers */, D710D48921949A85008F54AD /* ARTConstants.h in Headers */, D710D60921949DA9008F54AD /* ARTURLSessionServerTrust.h in Headers */, D710D51621949C42008F54AD /* ARTPush.h in Headers */, D737F827263AF4CE0064FA05 /* ARTFallbackHosts.h in Headers */, D710D4D521949BF9008F54AD /* ARTRealtimeChannel.h in Headers */, + 840FCE542C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */, 21276CBB29EF323100107B5F /* ARTContinuousClock.h in Headers */, D710D51721949C42008F54AD /* ARTPushChannel.h in Headers */, D710D51E21949C42008F54AD /* ARTLocalDeviceStorage.h in Headers */, @@ -2607,6 +2628,7 @@ D710D52A21949C44008F54AD /* ARTPushChannelSubscription.h in Headers */, D710D4BA21949B48008F54AD /* ARTAuth+Private.h in Headers */, D710D4C621949B9D008F54AD /* ARTRealtimeTransport.h in Headers */, + 844B9CD12C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */, D710D5A721949D2A008F54AD /* ARTTokenRequest.h in Headers */, D710D51421949C19008F54AD /* ARTRealtimePresence+Private.h in Headers */, D710D4AE21949AE0008F54AD /* ARTRestPresence.h in Headers */, @@ -2631,12 +2653,14 @@ 211A610529DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */, D7D06F1126330E2900DEBDAD /* ARTHttp+Private.h in Headers */, 210F67A429E9D718007B9345 /* ARTRealtimeTransportFactory.h in Headers */, + 84039A4E2C811F49001C053E /* ARTChannelOptions+Private.h in Headers */, EB1B541B22FB1D7F006A59AC /* ARTPushChannelSubscriptions+Private.h in Headers */, D710D48B21949A86008F54AD /* ARTConstants.h in Headers */, D710D60B21949DAA008F54AD /* ARTURLSessionServerTrust.h in Headers */, D710D52821949C44008F54AD /* ARTPush.h in Headers */, D737F828263AF4CE0064FA05 /* ARTFallbackHosts.h in Headers */, D710D4E521949BFB008F54AD /* ARTRealtimeChannel.h in Headers */, + 840FCE552C875B8A001163E1 /* ARTDevicePushDetails+Private.h in Headers */, 21276CBC29EF323100107B5F /* ARTContinuousClock.h in Headers */, D710D52921949C44008F54AD /* ARTPushChannel.h in Headers */, D710D53021949C44008F54AD /* ARTLocalDeviceStorage.h in Headers */, diff --git a/Source/ARTAuth.m b/Source/ARTAuth.m index 78a254f93..f5ab59e78 100644 --- a/Source/ARTAuth.m +++ b/Source/ARTAuth.m @@ -23,6 +23,7 @@ #import "ARTInternalLog.h" #import "ARTLocalDeviceStorage.h" #import "ARTLocalDevice+Private.h" +#import "ARTDeviceDetails+Private.h" @implementation ARTAuth { ARTQueuedDealloc *_dealloc; diff --git a/Source/ARTChannel.m b/Source/ARTChannel.m index d29fc40c3..225b71fc4 100644 --- a/Source/ARTChannel.m +++ b/Source/ARTChannel.m @@ -1,6 +1,6 @@ #import "ARTChannel+Private.h" #import "ARTChannel+Subclass.h" - +#import "ARTChannelOptions+Private.h" #import "ARTDataEncoder.h" #import "ARTMessage.h" #import "ARTChannelOptions.h" @@ -23,6 +23,7 @@ - (instancetype)initWithName:(NSString *)name andOptions:(ARTChannelOptions *)op _logger = logger; _queue = rest.queue; _options = options; + _options.frozen = YES; NSError *error = nil; _dataEncoder = [[ARTDataEncoder alloc] initWithCipherParams:_options.cipher logger:_logger error:&error]; if (error != nil) { diff --git a/Source/ARTChannelOptions.m b/Source/ARTChannelOptions.m index e18e22401..5da50e890 100644 --- a/Source/ARTChannelOptions.m +++ b/Source/ARTChannelOptions.m @@ -1,8 +1,10 @@ #import "ARTChannelOptions.h" - +#import "ARTChannelOptions+Private.h" #import "ARTEncoder.h" -@implementation ARTChannelOptions +@implementation ARTChannelOptions { + ARTCipherParams *_cipher; +} - (instancetype)initWithCipher:(id)cipherParams { if (self = [super init]) { @@ -15,4 +17,17 @@ - (instancetype)initWithCipherKey:(id)key { return [self initWithCipher:@{@"key": key}]; } +- (ARTCipherParams *)cipher { + return _cipher; +} + +- (void)setCipher:(ARTCipherParams *)cipher { + if (self.isFrozen) { + @throw [NSException exceptionWithName:NSObjectInaccessibleException + reason:[NSString stringWithFormat:@"%@: You can't change options after you've passed it to receiver.", self.class] + userInfo:nil]; + } + _cipher = cipher; +} + @end diff --git a/Source/ARTDeviceDetails.m b/Source/ARTDeviceDetails.m index 03e640bb3..1be635a91 100644 --- a/Source/ARTDeviceDetails.m +++ b/Source/ARTDeviceDetails.m @@ -1,5 +1,6 @@ #import "ARTDeviceDetails.h" #import "ARTDevicePushDetails.h" +#import "ARTDeviceDetails+Private.h" @implementation ARTDeviceDetails diff --git a/Source/ARTDevicePushDetails.m b/Source/ARTDevicePushDetails.m index 5cfa7e7e0..3fc3ed571 100644 --- a/Source/ARTDevicePushDetails.m +++ b/Source/ARTDevicePushDetails.m @@ -1,5 +1,6 @@ -#import "ARTDevicePushDetails.h" #import "ARTPush.h" +#import "ARTDevicePushDetails.h" +#import "ARTDevicePushDetails+Private.h" @implementation ARTDevicePushDetails diff --git a/Source/ARTJsonLikeEncoder.m b/Source/ARTJsonLikeEncoder.m index ff5358755..d63c08439 100644 --- a/Source/ARTJsonLikeEncoder.m +++ b/Source/ARTJsonLikeEncoder.m @@ -17,8 +17,10 @@ #import "ARTAuthDetails.h" #import "ARTPush.h" #import "ARTDeviceDetails.h" +#import "ARTDeviceDetails+Private.h" #import "ARTDeviceIdentityTokenDetails.h" #import "ARTDevicePushDetails.h" +#import "ARTDevicePushDetails+Private.h" #import "ARTConnectionDetails.h" #import "ARTRest+Private.h" #import "ARTJsonEncoder.h" diff --git a/Source/ARTLocalDevice.m b/Source/ARTLocalDevice.m index 5a73a80ec..581c4d2c0 100644 --- a/Source/ARTLocalDevice.m +++ b/Source/ARTLocalDevice.m @@ -1,4 +1,5 @@ #import "ARTLocalDevice+Private.h" +#import "ARTDeviceDetails+Private.h" #import "ARTDevicePushDetails.h" #import "ARTPush.h" #import "ARTEncoder.h" diff --git a/Source/ARTRealtimeChannelOptions.m b/Source/ARTRealtimeChannelOptions.m index 3f978cef8..a65606e96 100644 --- a/Source/ARTRealtimeChannelOptions.m +++ b/Source/ARTRealtimeChannelOptions.m @@ -1,5 +1,35 @@ #import "ARTRealtimeChannelOptions.h" +#import "ARTChannelOptions+Private.h" -@implementation ARTRealtimeChannelOptions +@implementation ARTRealtimeChannelOptions { + NSStringDictionary *_params; + ARTChannelMode _modes; +} + +- (NSStringDictionary *)params { + return _params; +} + +- (void)setParams:(NSStringDictionary *)params { + if (self.isFrozen) { + @throw [NSException exceptionWithName:NSObjectInaccessibleException + reason:[NSString stringWithFormat:@"%@: You can't change options after you've passed it to receiver.", self.class] + userInfo:nil]; + } + _params = params; +} + +- (ARTChannelMode)modes { + return _modes; +} + +- (void)setModes:(ARTChannelMode)modes { + if (self.isFrozen) { + @throw [NSException exceptionWithName:NSObjectInaccessibleException + reason:[NSString stringWithFormat:@"%@: You can't change options after you've passed it to receiver.", self.class] + userInfo:nil]; + } + _modes = modes; +} @end diff --git a/Source/Ably.modulemap b/Source/Ably.modulemap index 327d34883..fb003b9ad 100644 --- a/Source/Ably.modulemap +++ b/Source/Ably.modulemap @@ -36,6 +36,7 @@ framework module Ably { header "ARTWebSocketTransport+Private.h" header "ARTWebSocket.h" header "ARTClientOptions+Private.h" + header "ARTChannelOptions+Private.h" header "ARTCrypto+Private.h" header "ARTLog+Private.h" header "ARTRealtimePresence+Private.h" @@ -43,6 +44,8 @@ framework module Ably { header "ARTFallback+Private.h" header "ARTFallbackHosts.h" header "ARTLocalDevice+Private.h" + header "ARTDeviceDetails+Private.h" + header "ARTDevicePushDetails+Private.h" header "ARTPush+Private.h" header "ARTPushAdmin+Private.h" header "ARTPushDeviceRegistrations+Private.h" diff --git a/Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h b/Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h new file mode 100644 index 000000000..5bb3101b5 --- /dev/null +++ b/Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h @@ -0,0 +1,8 @@ +#import +#import + +@interface ARTChannelOptions () + +@property (nonatomic, getter=isFrozen) BOOL frozen; + +@end diff --git a/Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h b/Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h new file mode 100644 index 000000000..ea16cb86f --- /dev/null +++ b/Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h @@ -0,0 +1,19 @@ +#import +#import + +@class ARTDevicePushDetails; + +NS_ASSUME_NONNULL_BEGIN + +@interface ARTDeviceDetails () + +@property (nonatomic, readwrite) ARTDeviceId *id; +@property (nullable, nonatomic, readwrite) NSString *clientId; +@property (nonatomic, readwrite) NSString *platform; +@property (nonatomic, readwrite) NSString *formFactor; +@property (nonatomic, readwrite) NSDictionary *metadata; +@property (nonatomic, readwrite) ARTDevicePushDetails *push; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h b/Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h new file mode 100644 index 000000000..6d52d8c3c --- /dev/null +++ b/Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h @@ -0,0 +1,15 @@ +#import + +@class ARTErrorInfo; + +NS_ASSUME_NONNULL_BEGIN + +@interface ARTDevicePushDetails () + +@property (nonatomic, readwrite) NSMutableDictionary *recipient; +@property (nullable, nonatomic, readwrite) NSString *state; +@property (nullable, nonatomic, readwrite) ARTErrorInfo *errorReason; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h b/Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h index de9f0925c..271b8ba12 100644 --- a/Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h +++ b/Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h @@ -19,6 +19,7 @@ NSString* ARTAPNSDeviceTokenKeyOfType(NSString * _Nullable tokenType); @interface ARTLocalDevice () @property (nonatomic) id storage; +@property (nullable, nonatomic, readwrite) ARTDeviceSecret *secret; + (instancetype)deviceWithStorage:(id)storage logger:(nullable ARTInternalLog *)logger; - (nullable NSString *)apnsDeviceToken; diff --git a/Source/include/Ably/ARTAuth.h b/Source/include/Ably/ARTAuth.h index 3f1b8f35e..b7195c59b 100644 --- a/Source/include/Ably/ARTAuth.h +++ b/Source/include/Ably/ARTAuth.h @@ -88,6 +88,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTAuthProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTAuth : NSObject @end diff --git a/Source/include/Ably/ARTChannel.h b/Source/include/Ably/ARTChannel.h index fbd6393da..cb063f557 100644 --- a/Source/include/Ably/ARTChannel.h +++ b/Source/include/Ably/ARTChannel.h @@ -79,6 +79,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTChannelProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTChannel : NSObject /// :nodoc: diff --git a/Source/include/Ably/ARTChannels.h b/Source/include/Ably/ARTChannels.h index 03ac7bbba..bc0d3610d 100644 --- a/Source/include/Ably/ARTChannels.h +++ b/Source/include/Ably/ARTChannels.h @@ -7,6 +7,7 @@ /** * Creates and destroys `ARTRestChannel` and `ARTRealtimeChannel` objects. */ +NS_SWIFT_SENDABLE @interface ARTChannels : NSObject /** diff --git a/Source/include/Ably/ARTConnection.h b/Source/include/Ably/ARTConnection.h index aa25e2f56..ac61a970d 100644 --- a/Source/include/Ably/ARTConnection.h +++ b/Source/include/Ably/ARTConnection.h @@ -80,6 +80,7 @@ ART_EMBED_INTERFACE_EVENT_EMITTER(ARTRealtimeConnectionEvent, ARTConnectionState * * @see See `ARTConnectionProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTConnection: NSObject @end diff --git a/Source/include/Ably/ARTConnectionDetails.h b/Source/include/Ably/ARTConnectionDetails.h index 7121ebd60..61b798e30 100644 --- a/Source/include/Ably/ARTConnectionDetails.h +++ b/Source/include/Ably/ARTConnectionDetails.h @@ -5,6 +5,7 @@ /** * Contains any constraints a client should adhere to and provides additional metadata about a `ARTConnection`, such as if a request to `-[ARTChannelProtocol publish:callback:]` a message that exceeds the maximum message size should be rejected immediately without communicating with Ably. */ +NS_SWIFT_SENDABLE @interface ARTConnectionDetails : NSObject NS_ASSUME_NONNULL_BEGIN diff --git a/Source/include/Ably/ARTDataQuery.h b/Source/include/Ably/ARTDataQuery.h index 6f9d8ccbd..829d994d7 100755 --- a/Source/include/Ably/ARTDataQuery.h +++ b/Source/include/Ably/ARTDataQuery.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTQueryDirection) { ARTQueryDirectionForwards, ARTQueryDirectionBackwards diff --git a/Source/include/Ably/ARTDeviceDetails.h b/Source/include/Ably/ARTDeviceDetails.h index b996fc99c..f3832e3f7 100644 --- a/Source/include/Ably/ARTDeviceDetails.h +++ b/Source/include/Ably/ARTDeviceDetails.h @@ -8,37 +8,38 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the properties of a device registered for push notifications. */ +NS_SWIFT_SENDABLE @interface ARTDeviceDetails : NSObject /** * A unique ID generated by the device. */ -@property (nonatomic) ARTDeviceId *id; +@property (nonatomic, readonly) ARTDeviceId *id; /** * The client ID the device is connected to Ably with. */ -@property (nullable, nonatomic) NSString *clientId; +@property (nullable, nonatomic, readonly) NSString *clientId; /** * The `ARTDevicePlatform` associated with the device. Describes the platform the device uses, such as `android` or `ios`. */ -@property (nonatomic) NSString *platform; +@property (nonatomic, readonly) NSString *platform; /** * The `ARTDeviceFormFactor` object associated with the device. Describes the type of the device, such as `phone` or `tablet`. */ -@property (nonatomic) NSString *formFactor; +@property (nonatomic, readonly) NSString *formFactor; /** * A JSON object of key-value pairs that contains metadata for the device. */ -@property (nonatomic) NSDictionary *metadata; +@property (nonatomic, readonly) NSDictionary *metadata; /** * The `ARTDevicePushDetails` object associated with the device. Describes the details of the push registration of the device. */ -@property (nonatomic) ARTDevicePushDetails *push; +@property (nonatomic, readonly) ARTDevicePushDetails *push; /// :nodoc: - (instancetype)init; diff --git a/Source/include/Ably/ARTDevicePushDetails.h b/Source/include/Ably/ARTDevicePushDetails.h index 3822cd595..6c3b1c8cc 100644 --- a/Source/include/Ably/ARTDevicePushDetails.h +++ b/Source/include/Ably/ARTDevicePushDetails.h @@ -7,22 +7,23 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the details of the push registration of a device. */ +NS_SWIFT_SENDABLE @interface ARTDevicePushDetails : NSObject /** * A JSON object of key-value pairs that contains of the push transport and address. */ -@property (nonatomic) NSMutableDictionary *recipient; +@property (nonatomic, readonly) NSMutableDictionary *recipient; /** * The current state of the push registration. */ -@property (nullable, nonatomic) NSString *state; +@property (nullable, nonatomic, readonly) NSString *state; /** * An `ARTErrorInfo` object describing the most recent error when the `state` is `Failing` or `Failed`. */ -@property (nullable, nonatomic) ARTErrorInfo *errorReason; +@property (nullable, nonatomic, readonly) ARTErrorInfo *errorReason; /// :nodoc: - (instancetype)init; diff --git a/Source/include/Ably/ARTEventEmitter.h b/Source/include/Ably/ARTEventEmitter.h index d6d20a293..ea20e2fc8 100644 --- a/Source/include/Ably/ARTEventEmitter.h +++ b/Source/include/Ably/ARTEventEmitter.h @@ -23,12 +23,14 @@ NS_ASSUME_NONNULL_BEGIN /** An object representing a listener returned by `ARTEventEmitter` methods. */ +NS_SWIFT_SENDABLE @interface ARTEventListener : NSObject @end /** * A generic interface for event registration and delivery used in a number of the types in the Realtime client library. For example, the `ARTConnection` and `ARTRealtimeChannel` objects emit events for their state using the `ARTEventEmitter` pattern. */ +NS_SWIFT_SENDABLE @interface ARTEventEmitter, ItemType> : NSObject /// :nodoc: diff --git a/Source/include/Ably/ARTHTTPPaginatedResponse.h b/Source/include/Ably/ARTHTTPPaginatedResponse.h index 25ddbcae9..dded73d0b 100644 --- a/Source/include/Ably/ARTHTTPPaginatedResponse.h +++ b/Source/include/Ably/ARTHTTPPaginatedResponse.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A superset of `ARTPaginatedResult` which represents a page of results plus metadata indicating the relative queries available to it. `ARTHttpPaginatedResponse` additionally carries information about the response to an HTTP request. */ +NS_SWIFT_SENDABLE @interface ARTHTTPPaginatedResponse : ARTPaginatedResult /** diff --git a/Source/include/Ably/ARTLocalDevice.h b/Source/include/Ably/ARTLocalDevice.h index 25ef79639..36247f6c5 100644 --- a/Source/include/Ably/ARTLocalDevice.h +++ b/Source/include/Ably/ARTLocalDevice.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the device identity token and secret of a device. `ARTLocalDevice` extends `ARTDeviceDetails`. */ +NS_SWIFT_SENDABLE @interface ARTLocalDevice : ARTDeviceDetails /** @@ -18,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A unique device secret generated by the Ably SDK. */ -@property (nullable, nonatomic) ARTDeviceSecret *secret; +@property (nullable, nonatomic, readonly) ARTDeviceSecret *secret; /// :nodoc: - (instancetype)init NS_UNAVAILABLE; diff --git a/Source/include/Ably/ARTPaginatedResult.h b/Source/include/Ably/ARTPaginatedResult.h index f215f6c6f..a5b73561f 100644 --- a/Source/include/Ably/ARTPaginatedResult.h +++ b/Source/include/Ably/ARTPaginatedResult.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains a page of results for message or presence history, stats, or REST presence requests. An `ARTPaginatedResult` response from a REST API paginated query is also accompanied by metadata that indicates the relative queries available to the `ARTPaginatedResult` object. */ +NS_SWIFT_SENDABLE @interface ARTPaginatedResult : NSObject /** diff --git a/Source/include/Ably/ARTPresenceMessage.h b/Source/include/Ably/ARTPresenceMessage.h index a97411136..c5bf7bd9a 100644 --- a/Source/include/Ably/ARTPresenceMessage.h +++ b/Source/include/Ably/ARTPresenceMessage.h @@ -4,6 +4,7 @@ /** * Describes the possible actions members in the presence set can emit. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTPresenceAction) { /** * A member is not present in the channel. diff --git a/Source/include/Ably/ARTPush.h b/Source/include/Ably/ARTPush.h index 81b414995..fd5154d0c 100644 --- a/Source/include/Ably/ARTPush.h +++ b/Source/include/Ably/ARTPush.h @@ -111,6 +111,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Enables a device to be registered and deregistered from receiving push notifications. */ +NS_SWIFT_SENDABLE @interface ARTPush : NSObject /** diff --git a/Source/include/Ably/ARTPushAdmin.h b/Source/include/Ably/ARTPushAdmin.h index 27af1a2f4..2c0d724e4 100644 --- a/Source/include/Ably/ARTPushAdmin.h +++ b/Source/include/Ably/ARTPushAdmin.h @@ -27,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Enables the management of device registrations and push notification subscriptions. Also enables the publishing of push notifications to devices. */ +NS_SWIFT_SENDABLE @interface ARTPushAdmin : NSObject /** diff --git a/Source/include/Ably/ARTPushChannel.h b/Source/include/Ably/ARTPushChannel.h index ce2551ea0..c6070c46c 100644 --- a/Source/include/Ably/ARTPushChannel.h +++ b/Source/include/Ably/ARTPushChannel.h @@ -83,6 +83,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTPushChannelProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTPushChannel : NSObject @end diff --git a/Source/include/Ably/ARTPushChannelSubscriptions.h b/Source/include/Ably/ARTPushChannelSubscriptions.h index af06f0f08..eeeda92d6 100644 --- a/Source/include/Ably/ARTPushChannelSubscriptions.h +++ b/Source/include/Ably/ARTPushChannelSubscriptions.h @@ -62,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTPushChannelSubscriptionsProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTPushChannelSubscriptions : NSObject @end diff --git a/Source/include/Ably/ARTPushDeviceRegistrations.h b/Source/include/Ably/ARTPushDeviceRegistrations.h index 1738b9863..29fb1ae86 100644 --- a/Source/include/Ably/ARTPushDeviceRegistrations.h +++ b/Source/include/Ably/ARTPushDeviceRegistrations.h @@ -61,6 +61,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTPushDeviceRegistrationsProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTPushDeviceRegistrations : NSObject @end diff --git a/Source/include/Ably/ARTRealtime.h b/Source/include/Ably/ARTRealtime.h index fbf87b8b8..1eb23fd1b 100644 --- a/Source/include/Ably/ARTRealtime.h +++ b/Source/include/Ably/ARTRealtime.h @@ -104,6 +104,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A client that extends the functionality of the `ARTRest` and provides additional realtime-specific features. */ +NS_SWIFT_SENDABLE @interface ARTRealtime : NSObject /** diff --git a/Source/include/Ably/ARTRealtimeChannel.h b/Source/include/Ably/ARTRealtimeChannel.h index 6a153d8aa..baad506ab 100644 --- a/Source/include/Ably/ARTRealtimeChannel.h +++ b/Source/include/Ably/ARTRealtimeChannel.h @@ -149,6 +149,7 @@ ART_EMBED_INTERFACE_EVENT_EMITTER(ARTChannelEvent, ARTChannelStateChange *) * Enables messages to be published and subscribed to. Also enables historic messages to be retrieved and provides access to the `ARTRealtimePresence` object of a channel. * Also implements `ARTEventEmitter` interface and emits `ARTChannelEvent` events, where a `ARTChannelEvent` is either a `ARTRealtimeChannelState` or an `ARTChannelEvent.ARTChannelEventUpdate`. */ +NS_SWIFT_SENDABLE @interface ARTRealtimeChannel : NSObject /** diff --git a/Source/include/Ably/ARTRealtimeChannelOptions.h b/Source/include/Ably/ARTRealtimeChannelOptions.h index 2e5618d12..1bc622cd1 100644 --- a/Source/include/Ably/ARTRealtimeChannelOptions.h +++ b/Source/include/Ably/ARTRealtimeChannelOptions.h @@ -5,6 +5,7 @@ /** * Describes the possible flags used to configure client capabilities, using `ARTChannelOptions`. */ +NS_SWIFT_SENDABLE typedef NS_OPTIONS(NSUInteger, ARTChannelMode) { /** * The client can enter the presence set. diff --git a/Source/include/Ably/ARTRealtimeChannels.h b/Source/include/Ably/ARTRealtimeChannels.h index e927c3595..2ececfc30 100644 --- a/Source/include/Ably/ARTRealtimeChannels.h +++ b/Source/include/Ably/ARTRealtimeChannels.h @@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// :nodoc: +NS_SWIFT_SENDABLE @interface ARTRealtimeChannels : NSObject - (ARTRealtimeChannel *)get:(NSString *)name; diff --git a/Source/include/Ably/ARTRealtimePresence.h b/Source/include/Ably/ARTRealtimePresence.h index 6e22ef459..3bb3629a6 100644 --- a/Source/include/Ably/ARTRealtimePresence.h +++ b/Source/include/Ably/ARTRealtimePresence.h @@ -217,6 +217,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTRealtimePresenceProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTRealtimePresence : ARTPresence @end diff --git a/Source/include/Ably/ARTRest.h b/Source/include/Ably/ARTRest.h index ca9dbd0de..f1235a3d2 100644 --- a/Source/include/Ably/ARTRest.h +++ b/Source/include/Ably/ARTRest.h @@ -99,6 +99,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A client that offers a simple stateless API to interact directly with Ably's REST API. */ +NS_SWIFT_SENDABLE @interface ARTRest : NSObject /** diff --git a/Source/include/Ably/ARTRestChannel.h b/Source/include/Ably/ARTRestChannel.h index 2c25a3a2e..941c52b80 100644 --- a/Source/include/Ably/ARTRestChannel.h +++ b/Source/include/Ably/ARTRestChannel.h @@ -46,6 +46,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Enables messages to be published and historic messages to be retrieved for a channel. */ +NS_SWIFT_SENDABLE @interface ARTRestChannel : NSObject /** diff --git a/Source/include/Ably/ARTRestChannels.h b/Source/include/Ably/ARTRestChannels.h index 3a9bcc13e..b372859d4 100644 --- a/Source/include/Ably/ARTRestChannels.h +++ b/Source/include/Ably/ARTRestChannels.h @@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// :nodoc: +NS_SWIFT_SENDABLE @interface ARTRestChannels : NSObject - (ARTRestChannel *)get:(NSString *)name; diff --git a/Source/include/Ably/ARTRestPresence.h b/Source/include/Ably/ARTRestPresence.h index 0d24c00dc..f81f66fb9 100644 --- a/Source/include/Ably/ARTRestPresence.h +++ b/Source/include/Ably/ARTRestPresence.h @@ -78,6 +78,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTRestPresenceProtocol` for details. */ +NS_SWIFT_SENDABLE @interface ARTRestPresence : ARTPresence @end diff --git a/Source/include/Ably/ARTStats.h b/Source/include/Ably/ARTStats.h index e05a5b342..1f2c31dc1 100644 --- a/Source/include/Ably/ARTStats.h +++ b/Source/include/Ably/ARTStats.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Describes the interval unit over which statistics are gathered. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Interval unit over which statistics are gathered as minutes. diff --git a/Source/include/Ably/ARTStatus.h b/Source/include/Ably/ARTStatus.h index c36e83c8c..0102ba721 100644 --- a/Source/include/Ably/ARTStatus.h +++ b/Source/include/Ably/ARTStatus.h @@ -27,6 +27,7 @@ typedef NS_ENUM(NSUInteger, ARTState) { /** The list of all public error codes returned under the error domain ARTAblyErrorDomain */ +NS_SWIFT_SENDABLE typedef CF_ENUM(NSUInteger, ARTErrorCode) { ARTErrorNoError = 10000, ARTErrorBadRequest = 40000, diff --git a/Source/include/Ably/ARTTypes.h b/Source/include/Ably/ARTTypes.h index afdcda17a..bfc8f0c08 100644 --- a/Source/include/Ably/ARTTypes.h +++ b/Source/include/Ably/ARTTypes.h @@ -34,6 +34,7 @@ typedef NSData ARTDeviceToken; typedef ARTJsonObject ARTPushRecipient; /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTAuthentication) { ARTAuthenticationOff, ARTAuthenticationOn, @@ -43,6 +44,7 @@ typedef NS_ENUM(NSUInteger, ARTAuthentication) { }; /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTAuthMethod) { ARTAuthMethodBasic, ARTAuthMethodToken @@ -51,6 +53,7 @@ typedef NS_ENUM(NSUInteger, ARTAuthMethod) { /** * Describes the realtime `ARTConnection` object states. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTRealtimeConnectionState) { /** * A connection with this state has been initialized but no connection has yet been attempted. @@ -92,6 +95,7 @@ NSString *_Nonnull ARTRealtimeConnectionStateToStr(ARTRealtimeConnectionState st /** * Describes the events emitted by a `ARTConnection` object. An event is either an `ARTRealtimeConnectionEventUpdate` or an `ARTRealtimeConnectionState`. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTRealtimeConnectionEvent) { ARTRealtimeConnectionEventInitialized, ARTRealtimeConnectionEventConnecting, @@ -113,6 +117,7 @@ NSString *_Nonnull ARTRealtimeConnectionEventToStr(ARTRealtimeConnectionEvent ev /** * Describes the possible states of an `ARTRealtimeChannel` object. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTRealtimeChannelState) { /** * The channel has been initialized but no attach has yet been attempted. @@ -150,6 +155,7 @@ NSString *_Nonnull ARTRealtimeChannelStateToStr(ARTRealtimeChannelState state); /** * Describes the events emitted by an `ARTRealtimeChannel` object. An event is either an `ARTChannelEventUpdate` or a `ARTRealtimeChannelState`. */ +NS_SWIFT_SENDABLE typedef NS_ENUM(NSUInteger, ARTChannelEvent) { ARTChannelEventInitialized, ARTChannelEventAttaching, @@ -169,6 +175,7 @@ NSString *_Nonnull ARTChannelEventToStr(ARTChannelEvent event); /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSInteger, ARTDataQueryError) { ARTDataQueryErrorLimit = 1, ARTDataQueryErrorTimestampRange = 2, @@ -178,11 +185,13 @@ typedef NS_ENUM(NSInteger, ARTDataQueryError) { }; /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSInteger, ARTRealtimeHistoryError) { ARTRealtimeHistoryErrorNotAttached = ARTDataQueryErrorTimestampRange + 1 }; /// :nodoc: +NS_SWIFT_SENDABLE typedef NS_ENUM(NSInteger, ARTCustomRequestError) { ARTCustomRequestErrorInvalidMethod = 1, ARTCustomRequestErrorInvalidBody = 2, diff --git a/Test/Test Utilities/NSObject+TestSuite.h b/Test/Test Utilities/NSObject+TestSuite.h index cc61f6341..58c46e680 100644 --- a/Test/Test Utilities/NSObject+TestSuite.h +++ b/Test/Test Utilities/NSObject+TestSuite.h @@ -30,3 +30,5 @@ NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END @end + +NSException * _Nullable tryInObjC(void(NS_NOESCAPE^_Nonnull tryBlock)(void)); diff --git a/Test/Test Utilities/NSObject+TestSuite.m b/Test/Test Utilities/NSObject+TestSuite.m index dfabc8c3e..0267dbc2a 100644 --- a/Test/Test Utilities/NSObject+TestSuite.m +++ b/Test/Test Utilities/NSObject+TestSuite.m @@ -48,3 +48,13 @@ @implementation NSObject (TestSuite) } @end + +NSException * _Nullable tryInObjC(void(NS_NOESCAPE^_Nonnull tryBlock)(void)) { + @try { + tryBlock(); + } + @catch (NSException *exception) { + return exception; + } + return nil; +} diff --git a/Test/Tests/RealtimeClientChannelTests.swift b/Test/Tests/RealtimeClientChannelTests.swift index 752278d35..b29873c91 100644 --- a/Test/Tests/RealtimeClientChannelTests.swift +++ b/Test/Tests/RealtimeClientChannelTests.swift @@ -1687,10 +1687,12 @@ class RealtimeClientChannelTests: XCTestCase { } } - channelOptions.modes = [.subscribe] + let channelOptions2 = ARTRealtimeChannelOptions() + channelOptions2.params = ["rewind": "1"] + channelOptions2.modes = [.subscribe] let client2 = ARTRealtime(options: options) defer { client2.dispose(); client2.close() } - let channelWithoutAttachResume = client2.channels.get(channelName, options: channelOptions) + let channelWithoutAttachResume = client2.channels.get(channelName, options: channelOptions2) waitUntil(timeout: testTimeout) { done in channelWithoutAttachResume.subscribe { message in XCTAssertEqual(message.name, "test") @@ -4785,4 +4787,43 @@ class RealtimeClientChannelTests: XCTestCase { } } } + + // TB1 + func test__140__ChannelOptions__options_provided_when_instantiating_a_channel_should_be_frozen() throws { + let test = Test() + let options = try AblyTests.commonAppSetup(for: test) + options.autoConnect = false + let realtime = AblyTests.newRealtime(options).client + defer { realtime.dispose(); realtime.close() } + + let (keyData, ivData, _) = AblyTests.loadCryptoTestData("crypto-data-128") + let cipherParams = ARTCipherParams(algorithm: "aes", key: keyData as ARTCipherKeyCompatible, iv: ivData) + + let channelOptions = ARTRealtimeChannelOptions() + + // not frozen + channelOptions.cipher = cipherParams + channelOptions.modes = [.publish] + channelOptions.params = ["rewind": "1"] + + _ = realtime.channels.get(test.uniqueChannelName(), options: channelOptions) + + let exception1 = tryInObjC { + channelOptions.cipher = cipherParams // frozen + } + XCTAssertNotNil(exception1) + XCTAssertEqual(exception1!.name, NSExceptionName.objectInaccessibleException) + + let exception2 = tryInObjC { + channelOptions.modes = [.publish] // frozen + } + XCTAssertNotNil(exception2) + XCTAssertEqual(exception2!.name, NSExceptionName.objectInaccessibleException) + + let exception3 = tryInObjC { + channelOptions.params = ["rewind": "1"] // frozen + } + XCTAssertNotNil(exception3) + XCTAssertEqual(exception3!.name, NSExceptionName.objectInaccessibleException) + } }