Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions Source/ARTAnnotation.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<ARTJsonCompatible>)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)];
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTJsonLikeEncoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
maratal marked this conversation as resolved.
serial:[input artString:@"serial"]
messageSerial:[input artString:@"messageSerial"]
type:[input artString:@"type"]
Expand Down
5 changes: 1 addition & 4 deletions Source/ARTRealtimeAnnotations.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
}
Expand Down
3 changes: 0 additions & 3 deletions Source/ARTRestAnnotations.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
13 changes: 13 additions & 0 deletions Source/PrivateHeaders/Ably/ARTAnnotation+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ARTJsonCompatible>)extras;
Comment thread
maratal marked this conversation as resolved.

@end

NS_ASSUME_NONNULL_END
4 changes: 2 additions & 2 deletions Source/include/Ably/ARTAnnotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment thread
maratal marked this conversation as resolved.

/// This annotation's unique serial (lexicographically totally ordered).
@property (readonly, nonatomic) NSString *serial;
Expand All @@ -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
Expand Down
Loading