diff --git a/Source/ARTAnnotation.m b/Source/ARTAnnotation.m index 53f35d2c9..4ce0f0c6e 100644 --- a/Source/ARTAnnotation.m +++ b/Source/ARTAnnotation.m @@ -36,6 +36,29 @@ - (instancetype)initWithId:(NSString *)annotationId return self; } +- (instancetype)initWithId:(nullable NSString *)annotationId + action:(ARTAnnotationAction)action + clientId:(nullable NSString *)clientId + name:(nullable NSString *)name + count:(nullable NSNumber *)count + data:(nullable id)data + messageSerial:(NSString *)messageSerial + type:(NSString *)type + extras:(nullable id)extras { + if (self = [self init]) { + _id = annotationId; + _action = action; + _clientId = clientId; + _name = name; + _count = count; + _data = data; + _messageSerial = messageSerial; + _type = type; + _extras = extras; + } + return self; +} + - (NSString *)description { NSMutableString *description = [[super description] mutableCopy]; [description deleteCharactersInRange:NSMakeRange(description.length - (description.length>2 ? 2:0), 2)]; diff --git a/Source/ARTJsonLikeEncoder.m b/Source/ARTJsonLikeEncoder.m index 69fad01d2..b5890a4d4 100644 --- a/Source/ARTJsonLikeEncoder.m +++ b/Source/ARTJsonLikeEncoder.m @@ -473,7 +473,7 @@ - (ARTAnnotation *)annotationFromDictionary:(NSDictionary *)input { count:[input artNumber:@"count"] data:[input objectForKey:@"data"] encoding:[input artString:@"encoding"] - timestamp:[input artTimestamp:@"timestamp"] + timestamp:[input artTimestamp:@"timestamp"] ?: NSDate.date // see https://github.com/ably/ably-cocoa/issues/2124 serial:[input artString:@"serial"] messageSerial:[input artString:@"messageSerial"] type:[input artString:@"type"] diff --git a/Source/ARTRealtimeAnnotations.m b/Source/ARTRealtimeAnnotations.m index 072a08cec..e31327e9b 100644 --- a/Source/ARTRealtimeAnnotations.m +++ b/Source/ARTRealtimeAnnotations.m @@ -134,9 +134,6 @@ - (void)publishAnnotation:(ARTOutboundAnnotation *)outboundAnnotation name:outboundAnnotation.name count:outboundAnnotation.count data:outboundAnnotation.data - encoding:nil - timestamp:nil - serial:nil messageSerial:messageSerial // RSAN1c2 type:outboundAnnotation.type extras:outboundAnnotation.extras]; @@ -157,7 +154,7 @@ - (void)publishAnnotation:(ARTOutboundAnnotation *)outboundAnnotation if (annotationSize > maxSize) { if (callback) { callback([ARTErrorInfo createWithCode:ARTErrorMaxMessageLengthExceeded - message:[NSString stringWithFormat:@"Annotation size of %ld bytes exceeds maxMessageSize of %ld bytes", (long)annotationSize, (long)maxSize]]); + message:[NSString stringWithFormat:@"Annotation size of %ld bytes exceeds maxMessageSize of %ld bytes", (long)annotationSize, (long)maxSize]]); } return; } diff --git a/Source/ARTRestAnnotations.m b/Source/ARTRestAnnotations.m index 62db9ef48..fea0cd819 100644 --- a/Source/ARTRestAnnotations.m +++ b/Source/ARTRestAnnotations.m @@ -149,9 +149,6 @@ - (void)publishAnnotation:(ARTOutboundAnnotation *)outboundAnnotation name:outboundAnnotation.name count:outboundAnnotation.count data:outboundAnnotation.data - encoding:nil - timestamp:nil - serial:nil messageSerial:messageSerial // RSAN1c2 type:outboundAnnotation.type extras:outboundAnnotation.extras]; diff --git a/Source/PrivateHeaders/Ably/ARTAnnotation+Private.h b/Source/PrivateHeaders/Ably/ARTAnnotation+Private.h index e543f12cd..4866f6a59 100644 --- a/Source/PrivateHeaders/Ably/ARTAnnotation+Private.h +++ b/Source/PrivateHeaders/Ably/ARTAnnotation+Private.h @@ -13,6 +13,19 @@ NS_ASSUME_NONNULL_BEGIN - (NSInteger)annotationSize; +/** + * Internal initializer for converting outbound annotations to annotations before publishing + */ +- (instancetype)initWithId:(nullable NSString *)annotationId + action:(ARTAnnotationAction)action + clientId:(nullable NSString *)clientId + name:(nullable NSString *)name + count:(nullable NSNumber *)count + data:(nullable id)data + messageSerial:(NSString *)messageSerial + type:(NSString *)type + extras:(nullable id)extras; + @end NS_ASSUME_NONNULL_END diff --git a/Source/include/Ably/ARTAnnotation.h b/Source/include/Ably/ARTAnnotation.h index 3a5050b4a..644ffa1b5 100644 --- a/Source/include/Ably/ARTAnnotation.h +++ b/Source/include/Ably/ARTAnnotation.h @@ -47,7 +47,7 @@ NS_SWIFT_SENDABLE @property (nonatomic, readonly, nullable) NSString *encoding; /// Timestamp of when the message was received by Ably, as a `NSDate` object. -@property (nullable, nonatomic, readonly) NSDate *timestamp; +@property (readonly, nonatomic) NSDate *timestamp; /// This annotation's unique serial (lexicographically totally ordered). @property (readonly, nonatomic) NSString *serial; @@ -68,7 +68,7 @@ NS_SWIFT_SENDABLE count:(nullable NSNumber *)count data:(nullable id)data encoding:(nullable NSString *)encoding - timestamp:(nullable NSDate *)timestamp + timestamp:(NSDate *)timestamp serial:(nullable NSString *)serial messageSerial:(NSString *)messageSerial type:(NSString *)type