diff --git a/Framework/PubNub Framework.xcodeproj/project.pbxproj b/Framework/PubNub Framework.xcodeproj/project.pbxproj index c3293db01..ba7338404 100644 --- a/Framework/PubNub Framework.xcodeproj/project.pbxproj +++ b/Framework/PubNub Framework.xcodeproj/project.pbxproj @@ -2493,21 +2493,6 @@ A5A7B0332349330F0060113B /* PNBaseMessageActionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = A5A7AFF82349330F0060113B /* PNBaseMessageActionRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; A5A7B0342349330F0060113B /* PNBaseMessageActionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = A5A7AFF82349330F0060113B /* PNBaseMessageActionRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; A5A7B0362349330F0060113B /* PNBaseMessageActionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = A5A7AFF82349330F0060113B /* PNBaseMessageActionRequest.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A5CE35612959C45B0038FD6F /* PNMessageType.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE355F2959C45B0038FD6F /* PNMessageType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A5CE35622959C45B0038FD6F /* PNMessageType.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE355F2959C45B0038FD6F /* PNMessageType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A5CE35632959C45B0038FD6F /* PNMessageType.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE355F2959C45B0038FD6F /* PNMessageType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A5CE35642959C45B0038FD6F /* PNMessageType.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE355F2959C45B0038FD6F /* PNMessageType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A5CE35652959C45B0038FD6F /* PNMessageType.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE355F2959C45B0038FD6F /* PNMessageType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A5CE35662959C45B0038FD6F /* PNMessageType.m in Sources */ = {isa = PBXBuildFile; fileRef = A5CE35602959C45B0038FD6F /* PNMessageType.m */; }; - A5CE35672959C45B0038FD6F /* PNMessageType.m in Sources */ = {isa = PBXBuildFile; fileRef = A5CE35602959C45B0038FD6F /* PNMessageType.m */; }; - A5CE35682959C45B0038FD6F /* PNMessageType.m in Sources */ = {isa = PBXBuildFile; fileRef = A5CE35602959C45B0038FD6F /* PNMessageType.m */; }; - A5CE35692959C45B0038FD6F /* PNMessageType.m in Sources */ = {isa = PBXBuildFile; fileRef = A5CE35602959C45B0038FD6F /* PNMessageType.m */; }; - A5CE356A2959C45B0038FD6F /* PNMessageType.m in Sources */ = {isa = PBXBuildFile; fileRef = A5CE35602959C45B0038FD6F /* PNMessageType.m */; }; - A5CE356C2959C9260038FD6F /* PNMessageType+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE356B2959C9260038FD6F /* PNMessageType+Private.h */; }; - A5CE356D2959C9260038FD6F /* PNMessageType+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE356B2959C9260038FD6F /* PNMessageType+Private.h */; }; - A5CE356E2959C9260038FD6F /* PNMessageType+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE356B2959C9260038FD6F /* PNMessageType+Private.h */; }; - A5CE356F2959C9260038FD6F /* PNMessageType+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE356B2959C9260038FD6F /* PNMessageType+Private.h */; }; - A5CE35702959C9260038FD6F /* PNMessageType+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE356B2959C9260038FD6F /* PNMessageType+Private.h */; }; A5CE35732959D1E80038FD6F /* PNSpaceId.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE35712959D1E80038FD6F /* PNSpaceId.h */; settings = {ATTRIBUTES = (Public, ); }; }; A5CE35742959D1E80038FD6F /* PNSpaceId.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE35712959D1E80038FD6F /* PNSpaceId.h */; settings = {ATTRIBUTES = (Public, ); }; }; A5CE35752959D1E80038FD6F /* PNSpaceId.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CE35712959D1E80038FD6F /* PNSpaceId.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -3068,9 +3053,6 @@ A5A7AFF62349330E0060113B /* PNRemoveMessageActionRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PNRemoveMessageActionRequest.m; path = Message/PNRemoveMessageActionRequest.m; sourceTree = ""; }; A5A7AFF72349330F0060113B /* PNRemoveMessageActionRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PNRemoveMessageActionRequest.h; path = Message/PNRemoveMessageActionRequest.h; sourceTree = ""; }; A5A7AFF82349330F0060113B /* PNBaseMessageActionRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PNBaseMessageActionRequest.h; path = Message/PNBaseMessageActionRequest.h; sourceTree = ""; }; - A5CE355F2959C45B0038FD6F /* PNMessageType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNMessageType.h; sourceTree = ""; }; - A5CE35602959C45B0038FD6F /* PNMessageType.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PNMessageType.m; sourceTree = ""; }; - A5CE356B2959C9260038FD6F /* PNMessageType+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PNMessageType+Private.h"; sourceTree = ""; }; A5CE35712959D1E80038FD6F /* PNSpaceId.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNSpaceId.h; sourceTree = ""; }; A5CE35722959D1E80038FD6F /* PNSpaceId.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PNSpaceId.m; sourceTree = ""; }; A5FADC322490270E001D7704 /* PubNub+Files.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PubNub+Files.h"; sourceTree = ""; }; @@ -3822,9 +3804,6 @@ A55A86A722FD817E002D0A72 /* PNUUIDMetadata+Private.h */, A55A86A822FD817E002D0A72 /* PNUUIDMetadata.h */, A55A86A422FD817E002D0A72 /* PNUUIDMetadata.m */, - A5CE356B2959C9260038FD6F /* PNMessageType+Private.h */, - A5CE355F2959C45B0038FD6F /* PNMessageType.h */, - A5CE35602959C45B0038FD6F /* PNMessageType.m */, A5CE35712959D1E80038FD6F /* PNSpaceId.h */, A5CE35722959D1E80038FD6F /* PNSpaceId.m */, A58975E023005CFB0093BD9A /* PNMembership+Private.h */, @@ -4092,7 +4071,6 @@ 79AA8EC926EAB81500ADA747 /* PNConfiguration+Private.h in Headers */, A58975B223005AAC0093BD9A /* PNManageMembershipsStatus.h in Headers */, 79A238D01D2E70BD00D080CD /* NSURLSessionConfiguration+PNConfiguration.h in Headers */, - A5CE356C2959C9260038FD6F /* PNMessageType+Private.h in Headers */, 791582521BD709C60084FC70 /* PNPresenceChannelGroupHereNowResult.h in Headers */, 7932485E1D874D9F00FBDF36 /* PNPublishSequence.h in Headers */, 79A0D8441DC22C950039A264 /* PNAPNSAuditAPICallBuilder.h in Headers */, @@ -4204,7 +4182,6 @@ A55DAEFC24B1FE9E00766EE9 /* PNXML.h in Headers */, A55A87DC22FD8272002D0A72 /* PNBaseObjectsRequest.h in Headers */, A57A3089238D751400DE8C68 /* PNMPNSNotificationPayload.h in Headers */, - A5CE35612959C45B0038FD6F /* PNMessageType.h in Headers */, 79A0D86E1DC22C950039A264 /* PNAPICallBuilder+Private.h in Headers */, A57A30E9238DCAAF00DE8C68 /* PNAPNSNotificationTarget+Private.h in Headers */, A55A881B22FD8272002D0A72 /* PNFetchAllChannelsMetadataRequest.h in Headers */, @@ -4370,7 +4347,6 @@ 79AA8ECB26EAB81500ADA747 /* PNConfiguration+Private.h in Headers */, A58975B423005AAC0093BD9A /* PNManageMembershipsStatus.h in Headers */, 791583201BD709D10084FC70 /* PNPushNotificationsStateModificationParser.h in Headers */, - A5CE356E2959C9260038FD6F /* PNMessageType+Private.h in Headers */, 79A238D21D2E70BD00D080CD /* NSURLSessionConfiguration+PNConfiguration.h in Headers */, 791582FB1BD709D10084FC70 /* PNPresenceChannelGroupHereNowResult.h in Headers */, 793248601D874D9F00FBDF36 /* PNPublishSequence.h in Headers */, @@ -4482,7 +4458,6 @@ A55DAEFE24B1FE9E00766EE9 /* PNXML.h in Headers */, A55A87DE22FD8272002D0A72 /* PNBaseObjectsRequest.h in Headers */, A57A308B238D751400DE8C68 /* PNMPNSNotificationPayload.h in Headers */, - A5CE35632959C45B0038FD6F /* PNMessageType.h in Headers */, 791583111BD709D10084FC70 /* PNHistoryResult.h in Headers */, A57A30EB238DCAAF00DE8C68 /* PNAPNSNotificationTarget+Private.h in Headers */, A55A881D22FD8272002D0A72 /* PNFetchAllChannelsMetadataRequest.h in Headers */, @@ -4691,7 +4666,6 @@ A5A7B0132349330F0060113B /* PNAddMessageActionRequest.h in Headers */, A55BCCFB231D222B0019DB68 /* PNRemoveMessageActionAPICallBuilder.h in Headers */, 7960B6691F68122200FFAEBB /* PNDeleteMessageAPICallBuilder.h in Headers */, - A5CE35652959C45B0038FD6F /* PNMessageType.h in Headers */, A55DAF0B24B1FEC800766EE9 /* PNXML+Private.h in Headers */, A504E15824AA9CFB006DCF5B /* PNFilesAPICallBuilder.h in Headers */, A57A308E238D751400DE8C68 /* PNMPNSNotificationPayload.h in Headers */, @@ -4878,7 +4852,6 @@ 7925DB8C1D3FFCAC00857C0D /* PNLLogger.h in Headers */, 79CFA2BD26DE1C4900D206D4 /* PNPAMToken.h in Headers */, 79A3E4142215699900F2ADB9 /* PNMessageCountAPICallBuilder.h in Headers */, - A5CE35702959C9260038FD6F /* PNMessageType+Private.h in Headers */, A55A866222FD80B9002D0A72 /* PNFetchChannelMetadataAPICallBuilder.h in Headers */, 79ABD8961F01636B007634E0 /* PNTelemetry.h in Headers */, 7988427F1C18F286003E8948 /* PNNumber.h in Headers */, @@ -4925,7 +4898,6 @@ 79AA8ECA26EAB81500ADA747 /* PNConfiguration+Private.h in Headers */, A58975B323005AAC0093BD9A /* PNManageMembershipsStatus.h in Headers */, 79A8BC8D1C58F93900015BDE /* PNPushNotificationsStateModificationParser.h in Headers */, - A5CE356D2959C9260038FD6F /* PNMessageType+Private.h in Headers */, 79A238D11D2E70BD00D080CD /* NSURLSessionConfiguration+PNConfiguration.h in Headers */, 79A8BC681C58F93900015BDE /* PNPresenceChannelGroupHereNowResult.h in Headers */, 7932485F1D874D9F00FBDF36 /* PNPublishSequence.h in Headers */, @@ -5037,7 +5009,6 @@ A55DAEFD24B1FE9E00766EE9 /* PNXML.h in Headers */, A55A87DD22FD8272002D0A72 /* PNBaseObjectsRequest.h in Headers */, A57A308A238D751400DE8C68 /* PNMPNSNotificationPayload.h in Headers */, - A5CE35622959C45B0038FD6F /* PNMessageType.h in Headers */, 79A8BC7E1C58F93900015BDE /* PNHistoryResult.h in Headers */, A57A30EA238DCAAF00DE8C68 /* PNAPNSNotificationTarget+Private.h in Headers */, A55A881C22FD8272002D0A72 /* PNFetchAllChannelsMetadataRequest.h in Headers */, @@ -5203,7 +5174,6 @@ 79AA8ECC26EAB81500ADA747 /* PNConfiguration+Private.h in Headers */, A58975B523005AAC0093BD9A /* PNManageMembershipsStatus.h in Headers */, 79E20D2C1C8B0AD5001BC9CC /* PNPushNotificationsStateModificationParser.h in Headers */, - A5CE356F2959C9260038FD6F /* PNMessageType+Private.h in Headers */, 79A238D31D2E70BD00D080CD /* NSURLSessionConfiguration+PNConfiguration.h in Headers */, 79E20D2B1C8B0A70001BC9CC /* PNPresenceChannelGroupHereNowResult.h in Headers */, 793248611D874D9F00FBDF36 /* PNPublishSequence.h in Headers */, @@ -5315,7 +5285,6 @@ A55DAEFF24B1FE9E00766EE9 /* PNXML.h in Headers */, A55A87DF22FD8272002D0A72 /* PNBaseObjectsRequest.h in Headers */, A57A308C238D751400DE8C68 /* PNMPNSNotificationPayload.h in Headers */, - A5CE35642959C45B0038FD6F /* PNMessageType.h in Headers */, 79CBB11A1BD03DE4001FC34D /* PNConfiguration.h in Headers */, A57A30EC238DCAAF00DE8C68 /* PNAPNSNotificationTarget+Private.h in Headers */, A55A881E22FD8272002D0A72 /* PNFetchAllChannelsMetadataRequest.h in Headers */, @@ -6115,7 +6084,6 @@ A56865702300709F0014E17C /* PNFetchMembershipsResult.m in Sources */, A56FAEF9233161570072ADD6 /* PubNub+MessageActions.m in Sources */, 79A0D8651DC22C950039A264 /* PNSubscribeAPIBuilder.m in Sources */, - A5CE35662959C45B0038FD6F /* PNMessageType.m in Sources */, A5046F2424784CAB0008C81E /* PNObjectsRemoveParser.m in Sources */, A5046F1D24784CAB0008C81E /* PNRemoveUUIDMetadataRequest.m in Sources */, A5046F0B24784CAB0008C81E /* PNMembership.m in Sources */, @@ -6347,7 +6315,6 @@ A56865722300709F0014E17C /* PNFetchMembershipsResult.m in Sources */, A56FAEFB233161570072ADD6 /* PubNub+MessageActions.m in Sources */, 79A0D96D1DC2313A0039A264 /* PNSubscribeChannelsOrGroupsAPIBuilder.m in Sources */, - A5CE35682959C45B0038FD6F /* PNMessageType.m in Sources */, A5046EC624784CAA0008C81E /* PNObjectsRemoveParser.m in Sources */, A5046EBF24784CAA0008C81E /* PNRemoveUUIDMetadataRequest.m in Sources */, A5046EAD24784CAA0008C81E /* PNMembership.m in Sources */, @@ -6579,7 +6546,6 @@ A56865752300709F0014E17C /* PNFetchMembershipsResult.m in Sources */, A56FAEFE233161570072ADD6 /* PubNub+MessageActions.m in Sources */, 79A0D96F1DC2313B0039A264 /* PNSubscribeChannelsOrGroupsAPIBuilder.m in Sources */, - A5CE356A2959C45B0038FD6F /* PNMessageType.m in Sources */, A5046E6824784CA90008C81E /* PNObjectsRemoveParser.m in Sources */, A5046E6124784CA90008C81E /* PNRemoveUUIDMetadataRequest.m in Sources */, A5046E4F24784CA90008C81E /* PNMembership.m in Sources */, @@ -6811,7 +6777,6 @@ A56865712300709F0014E17C /* PNFetchMembershipsResult.m in Sources */, A56FAEFA233161570072ADD6 /* PubNub+MessageActions.m in Sources */, 79A0D96E1DC2313A0039A264 /* PNSubscribeChannelsOrGroupsAPIBuilder.m in Sources */, - A5CE35672959C45B0038FD6F /* PNMessageType.m in Sources */, A5046EF524784CAB0008C81E /* PNObjectsRemoveParser.m in Sources */, A5046EEE24784CAB0008C81E /* PNRemoveUUIDMetadataRequest.m in Sources */, A5046EDC24784CAB0008C81E /* PNMembership.m in Sources */, @@ -7043,7 +7008,6 @@ A56865732300709F0014E17C /* PNFetchMembershipsResult.m in Sources */, A56FAEFC233161570072ADD6 /* PubNub+MessageActions.m in Sources */, 79A0D9711DC2313C0039A264 /* PNSubscribeChannelsOrGroupsAPIBuilder.m in Sources */, - A5CE35692959C45B0038FD6F /* PNMessageType.m in Sources */, A5046E9724784CAA0008C81E /* PNObjectsRemoveParser.m in Sources */, A5046E9024784CAA0008C81E /* PNRemoveUUIDMetadataRequest.m in Sources */, A5046E7E24784CAA0008C81E /* PNMembership.m in Sources */, diff --git a/Framework/PubNub/PubNub.h b/Framework/PubNub/PubNub.h index 3f5960cd8..0bf203d24 100644 --- a/Framework/PubNub/PubNub.h +++ b/Framework/PubNub/PubNub.h @@ -55,7 +55,6 @@ FOUNDATION_EXPORT const unsigned char PubNubVersionString[]; #import "PNStatus.h" // Models -#import "PNMessageType.h" #import "PNSpaceId.h" // API diff --git a/PubNub/Core/PubNub+Files.h b/PubNub/Core/PubNub+Files.h index ec5b7afa9..ed21c8759 100644 --- a/PubNub/Core/PubNub+Files.h +++ b/PubNub/Core/PubNub+Files.h @@ -3,7 +3,6 @@ #import "PNDeleteFileRequest.h" #import "PNListFilesRequest.h" #import "PNSendFileRequest.h" -#import "PNMessageType.h" #import "PNSpaceId.h" #import "PNFile.h" diff --git a/PubNub/Core/PubNub+Files.m b/PubNub/Core/PubNub+Files.m index 19c8fec77..d3a479d18 100644 --- a/PubNub/Core/PubNub+Files.m +++ b/PubNub/Core/PubNub+Files.m @@ -189,7 +189,7 @@ - (void)sendFileRequestUsingBuilderParameters:(NSDictionary *)parameters { request.cipherKey = cipherKey ?: self.configuration.cipherKey; request.fileMessageMetadata = parameters[NSStringFromSelector(@selector(fileMessageMetadata))]; request.arbitraryQueryParameters = parameters[@"queryParam"]; - request.messageType = parameters[NSStringFromSelector(@selector(messageType))]; + request.type = parameters[NSStringFromSelector(@selector(type))]; request.spaceId = parameters[NSStringFromSelector(@selector(spaceId))]; request.message = parameters[NSStringFromSelector(@selector(message))]; @@ -508,7 +508,7 @@ - (void)handleUploadFileSuccessWithFileIdentifier:(NSString *)fileIdentifier request.arbitraryQueryParameters = sendFileRequest.arbitraryQueryParameters; request.metadata = sendFileRequest.fileMessageMetadata; - request.messageType = sendFileRequest.messageType; + request.type = sendFileRequest.type; request.store = sendFileRequest.fileMessageStore; request.spaceId = sendFileRequest.spaceId; request.message = sendFileRequest.message; diff --git a/PubNub/Core/PubNub+History.m b/PubNub/Core/PubNub+History.m index 44b78dfb8..5ed345cdc 100644 --- a/PubNub/Core/PubNub+History.m +++ b/PubNub/Core/PubNub+History.m @@ -43,6 +43,8 @@ @interface PubNub (HistoryProtected) * not. * @param includeMessageType Whether event type should be included in response or not. * By default set to: \b YES. + * @param includeType Whether user-provided event type should be included in response or not. + * By default set to: \b YES. * @param includeSpaceId Whether identifier of space to which event has been sent should be included or not. * @param includeUUID Whether event publisher UUID should be included in response or not. * By default set to: \b YES. @@ -62,6 +64,7 @@ - (void)historyForChannels:(BOOL)multipleChannels reverse:(nullable NSNumber *)shouldReverseOrder includeTimeToken:(nullable NSNumber *)shouldIncludeTimeToken includeMessageType:(nullable NSNumber *)includeMessageType + includeType:(nullable NSNumber *)includeType includeSpaceId:(nullable NSNumber *)includeSpaceId includeUUID:(nullable NSNumber *)includeUUID includeMessageActions:(nullable NSNumber *)shouldIncludeMessageActions @@ -155,6 +158,7 @@ @implementation PubNub (History) NSNumber *reverse = parameters[NSStringFromSelector(@selector(reverse))]; NSNumber *includeTimeToken = parameters[NSStringFromSelector(@selector(includeTimeToken))]; NSNumber *includeMessageType = parameters[NSStringFromSelector(@selector(includeMessageType))]; + NSNumber *includeType = parameters[NSStringFromSelector(@selector(includeType))]; NSNumber *includeSpaceId = parameters[NSStringFromSelector(@selector(includeSpaceId))]; NSNumber *includeUUID = parameters[NSStringFromSelector(@selector(includeUUID))]; NSNumber *includeMetadata = parameters[NSStringFromSelector(@selector(includeMetadata))]; @@ -170,6 +174,7 @@ @implementation PubNub (History) reverse:reverse includeTimeToken:includeTimeToken includeMessageType:includeMessageType + includeType:includeType includeSpaceId:includeSpaceId includeUUID:includeUUID includeMessageActions:includeActions @@ -320,6 +325,7 @@ - (void)historyForChannel:(NSString *)channel reverse:@NO includeTimeToken:@NO includeMessageType:@YES + includeType:@YES includeSpaceId:@NO includeUUID:@YES includeMessageActions:@(shouldIncludeMessageActions) @@ -408,6 +414,7 @@ - (void)historyForChannel:(NSString *)channel reverse:@(shouldReverseOrder) includeTimeToken:@(shouldIncludeTimeToken) includeMessageType:@YES + includeType:@YES includeSpaceId:@NO includeUUID:@YES includeMessageActions:nil @@ -424,6 +431,7 @@ - (void)historyForChannels:(BOOL)multipleChannels reverse:(NSNumber *)shouldReverseOrder includeTimeToken:(NSNumber *)shouldIncludeTimeToken includeMessageType:(NSNumber *)includeMessageType + includeType:(NSNumber *)includeType includeSpaceId:(NSNumber *)includeSpaceId includeUUID:(NSNumber *)includeUUID includeMessageActions:(NSNumber *)shouldIncludeMessageActions @@ -443,10 +451,14 @@ - (void)historyForChannels:(BOOL)multipleChannels if (!limit || limit.unsignedIntValue == 0) { limit = nil; } - + if (!includeMessageType) { includeMessageType = @YES; } + + if (!includeType) { + includeType = @YES; + } if (!includeSpaceId) { includeSpaceId = @NO; @@ -519,7 +531,7 @@ - (void)historyForChannels:(BOOL)multipleChannels if (operation == PNHistoryWithActionsOperation || multipleChannels) { [parameters addQueryParameter:(includeMessageType.boolValue ? @"true" : @"false") forFieldName:@"include_message_type"]; - [parameters addQueryParameter:(includeMessageType.boolValue ? @"true" : @"false") + [parameters addQueryParameter:(includeType.boolValue ? @"true" : @"false") forFieldName:@"include_type"]; [parameters addQueryParameter:(includeSpaceId.boolValue ? @"true" : @"false") forFieldName:@"include_space_id"]; @@ -584,6 +596,7 @@ - (void)historyForChannels:(BOOL)multipleChannels reverse:shouldReverseOrder includeTimeToken:shouldIncludeTimeToken includeMessageType:includeMessageType + includeType:includeType includeSpaceId:includeSpaceId includeUUID:includeUUID includeMessageActions:shouldIncludeMessageActions diff --git a/PubNub/Core/PubNub+Publish.h b/PubNub/Core/PubNub+Publish.h index b2db8a6f8..5cbe88f3b 100644 --- a/PubNub/Core/PubNub+Publish.h +++ b/PubNub/Core/PubNub+Publish.h @@ -3,7 +3,6 @@ #import "PNPublishFileMessageRequest.h" #import "PNPublishRequest.h" -#import "PNMessageType.h" #import "PNSpaceId.h" #import "PNPublishFileMessageAPICallBuilder.h" diff --git a/PubNub/Core/PubNub+Publish.m b/PubNub/Core/PubNub+Publish.m index 307f9ccc8..7df188ec7 100644 --- a/PubNub/Core/PubNub+Publish.m +++ b/PubNub/Core/PubNub+Publish.m @@ -51,7 +51,7 @@ @interface PubNub (PublishProtected) * @since 4.8.2 */ - (void)publish:(nullable id)message - withType:(nullable PNMessageType *)type + withType:(nullable NSString *)type toChannel:(NSString *)channel spaceId:(nullable PNSpaceId *)spaceId mobilePushPayload:(nullable NSDictionary *)payloads @@ -74,7 +74,7 @@ - (void)publish:(nullable id)message * * @param message Object (\a NSString, \a NSNumber, \a NSArray, \a NSDictionary) which will be * sent with signal. - * @param messageType Type with which signal should be published. + * @param type Type with which signal should be published. * @param channel Name of the channel to which signal should be sent. * @param spaceId Identifier of space to which signal should be published. * @param queryParameters List arbitrary query parameters which should be sent along with original @@ -84,7 +84,7 @@ - (void)publish:(nullable id)message * @since 4.9.0 */ - (void)signal:(id)message - withType:(nullable PNMessageType *)messageType + withType:(nullable NSString *)type channel:(NSString *)channel spaceId:(nullable PNSpaceId *)spaceId withQueryParameters:(nullable NSDictionary *)queryParameters @@ -118,7 +118,7 @@ - (void)signal:(id)message * @since 4.8.2 */ - (void)sizeOfMessage:(id)message - withType:(nullable PNMessageType *)type + withType:(nullable NSString *)type toChannel:(NSString *)channel spaceId:(nullable PNSpaceId *)spaceId compressed:(BOOL)compressMessage @@ -174,7 +174,7 @@ - (void)handlePublishBuilderExecutionWithFlags:(NSArray *)flags * @since 4.0 */ - (PNRequestParameters *)requestParametersForMessage:(NSString *)message - withType:(nullable PNMessageType *)type + withType:(nullable NSString *)type toChannel:(NSString *)channel spaceId:(nullable PNSpaceId *)spaceId compressed:(BOOL)compressMessage @@ -257,7 +257,7 @@ @implementation PubNub (Publish) PNPublishFileMessageRequest *request = [PNPublishFileMessageRequest requestWithChannel:channel fileIdentifier:identifier name:filename]; - request.messageType = parameters[NSStringFromSelector(@selector(messageType))]; + request.type = parameters[NSStringFromSelector(@selector(type))]; request.metadata = parameters[NSStringFromSelector(@selector(metadata))]; request.spaceId = parameters[NSStringFromSelector(@selector(spaceId))]; request.message = parameters[NSStringFromSelector(@selector(message))]; @@ -295,7 +295,7 @@ @implementation PubNub (Publish) request.metadata = parameters[NSStringFromSelector(@selector(metadata))]; request.payloads = parameters[NSStringFromSelector(@selector(payloads))]; request.message = parameters[NSStringFromSelector(@selector(message))]; - request.messageType = parameters[NSStringFromSelector(@selector(messageType))]; + request.type = parameters[NSStringFromSelector(@selector(type))]; request.arbitraryQueryParameters = parameters[@"queryParam"]; request.store = (shouldStore ? shouldStore.boolValue : YES); request.replicate = (replicate ? replicate.boolValue : YES); @@ -336,14 +336,14 @@ @implementation PubNub (Publish) NSDictionary *parameters) { id message = parameters[NSStringFromSelector(@selector(message))]; - PNMessageType *messageType = parameters[NSStringFromSelector(@selector(messageType))]; + NSString *type = parameters[NSStringFromSelector(@selector(type))]; NSString *channel = parameters[NSStringFromSelector(@selector(channel))]; PNSpaceId *spaceId = parameters[NSStringFromSelector(@selector(spaceId))]; NSDictionary *queryParam = parameters[@"queryParam"]; id block = parameters[@"block"]; [weakSelf signal:message - withType:messageType + withType:type channel:channel spaceId:spaceId withQueryParameters:queryParam @@ -361,7 +361,7 @@ @implementation PubNub (Publish) NSDictionary *parameters) { id message = parameters[NSStringFromSelector(@selector(message))]; - PNMessageType *messageType = parameters[NSStringFromSelector(@selector(messageType))]; + NSString *type = parameters[NSStringFromSelector(@selector(type))]; NSString *channel = parameters[NSStringFromSelector(@selector(channel))]; PNSpaceId *spaceId = parameters[NSStringFromSelector(@selector(spaceId))]; NSNumber *shouldStore = parameters[NSStringFromSelector(@selector(shouldStore))]; @@ -377,7 +377,7 @@ @implementation PubNub (Publish) } [self sizeOfMessage:message - withType:messageType + withType:type toChannel:channel spaceId:spaceId compressed:compressed.boolValue @@ -442,8 +442,7 @@ - (void)publishWithRequest:(PNPublishRequest *)request completion:(PNPublishComp PNLogAPICall(self.logger, @" Publish%@ message%@ to '%@' channel%@%@%@%@", (request.shouldCompress ? @" compressed" : @""), - (request.messageType ? [NSString stringWithFormat:@" of '%@' type", - request.messageType.value] : @""), + (request.type ? [NSString stringWithFormat:@" of '%@' type", request.type] : @""), (request.channel ?: @""), (request.spaceId ? [NSString stringWithFormat:@" (space id: %@)", request.spaceId.value] : @""), @@ -695,7 +694,7 @@ - (void)publish:(id)message } - (void)publish:(id)message - withType:(PNMessageType *)messageType + withType:(NSString *)type toChannel:(NSString *)channel spaceId:(PNSpaceId *)spaceId mobilePushPayload:(NSDictionary *)payloads @@ -717,7 +716,7 @@ - (void)publish:(id)message request.payloads = payloads; request.store = shouldStore; request.message = message; - request.messageType = messageType; + request.type = type; [self publishWithRequest:request completion:block]; } @@ -733,7 +732,7 @@ - (void)signal:(id)message } - (void)signal:(id)message - withType:(PNMessageType *)messageType + withType:(NSString *)type channel:(NSString *)channel spaceId:(PNSpaceId *)spaceId withQueryParameters:(NSDictionary *)queryParameters @@ -771,8 +770,8 @@ - (void)signal:(id)message forPlaceholder:@"{message}"]; } - if (messageType) { - [parameters addQueryParameter:messageType.value forFieldName:@"type"]; + if (type) { + [parameters addQueryParameter:type forFieldName:@"type"]; } PNLogAPICall(strongSelf.logger, @" Signal to '%@' channel.", @@ -786,7 +785,7 @@ - (void)signal:(id)message if (status.isError) { status.retryBlock = ^{ [weakSelf signal:message - withType:messageType + withType:type channel:channel spaceId:spaceId withQueryParameters:queryParameters @@ -908,7 +907,7 @@ - (void)sizeOfMessage:(id)message } - (void)sizeOfMessage:(id)message - withType:(PNMessageType *)messageType + withType:(NSString *)type toChannel:(NSString *)channel spaceId:(PNSpaceId *)spaceId compressed:(BOOL)compressMessage @@ -956,7 +955,7 @@ - (void)sizeOfMessage:(id)message } PNRequestParameters *parameters = [self requestParametersForMessage:messageForPublish - withType:messageType + withType:type toChannel:channel spaceId:spaceId compressed:compressMessage @@ -991,7 +990,7 @@ - (void)handlePublishBuilderExecutionWithFlags:(NSArray *)flags parameters:(NSDictionary *)parameters { id message = parameters[NSStringFromSelector(@selector(message))]; - PNMessageType *messageType = parameters[NSStringFromSelector(@selector(messageType))]; + NSString *type = parameters[NSStringFromSelector(@selector(type))]; NSString *channel = parameters[NSStringFromSelector(@selector(channel))]; PNSpaceId *spaceId = parameters[NSStringFromSelector(@selector(spaceId))]; NSDictionary *payloads = parameters[NSStringFromSelector(@selector(payloads))]; @@ -1003,7 +1002,7 @@ - (void)handlePublishBuilderExecutionWithFlags:(NSArray *)flags NSDictionary *metadata = parameters[NSStringFromSelector(@selector(metadata))]; [self publish:message - withType:messageType + withType:type toChannel:channel spaceId:spaceId mobilePushPayload:payloads @@ -1020,7 +1019,7 @@ - (void)handlePublishBuilderExecutionWithFlags:(NSArray *)flags #pragma mark - Misc - (PNRequestParameters *)requestParametersForMessage:(NSString *)message - withType:(PNMessageType *)messageType + withType:(NSString *)type toChannel:(NSString *)channel spaceId:(PNSpaceId *)spaceId compressed:(BOOL)compressMessage @@ -1061,8 +1060,8 @@ - (PNRequestParameters *)requestParametersForMessage:(NSString *)message [parameters addPathComponent:targetMessage forPlaceholder:@"{message}"]; } - if (messageType) { - [parameters addQueryParameter:messageType.value forFieldName:@"type"]; + if (type) { + [parameters addQueryParameter:type forFieldName:@"type"]; } if ([metadata isKindOfClass:[NSString class]] && metadata.length) { diff --git a/PubNub/Data/Builders/API Call/Files/PNSendFileAPICallBuilder.h b/PubNub/Data/Builders/API Call/Files/PNSendFileAPICallBuilder.h index 77b7d06c4..ed6e89250 100644 --- a/PubNub/Data/Builders/API Call/Files/PNSendFileAPICallBuilder.h +++ b/PubNub/Data/Builders/API Call/Files/PNSendFileAPICallBuilder.h @@ -5,7 +5,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark Class forward -@class PNSpaceId, PNMessageType; +@class PNSpaceId; #pragma mark - Interface declaration @@ -104,13 +104,13 @@ NS_ASSUME_NONNULL_BEGIN /** * @brief Type of message which will be published. * - * @param type Custom type for published message. + * @param type User-provided type for published message. * * @return API call configuration builder. * * @version 5.2.0 */ -@property (nonatomic, readonly, strong) PNSendFileAPICallBuilder * (^messageType)(PNMessageType *type); +@property (nonatomic, readonly, strong) PNSendFileAPICallBuilder * (^type)(NSString *type); /** * @brief In-memory binary data which should be uploaded and available in target channel. diff --git a/PubNub/Data/Builders/API Call/Files/PNSendFileAPICallBuilder.m b/PubNub/Data/Builders/API Call/Files/PNSendFileAPICallBuilder.m index e1011bf25..08dedd86e 100644 --- a/PubNub/Data/Builders/API Call/Files/PNSendFileAPICallBuilder.m +++ b/PubNub/Data/Builders/API Call/Files/PNSendFileAPICallBuilder.m @@ -82,9 +82,9 @@ @implementation PNSendFileAPICallBuilder }; } -- (PNSendFileAPICallBuilder * (^)(PNMessageType *messageType))messageType { - return ^PNSendFileAPICallBuilder * (PNMessageType *messageType) { - [self setValue:messageType forParameter:NSStringFromSelector(_cmd)]; +- (PNSendFileAPICallBuilder * (^)(NSString *type))type { + return ^PNSendFileAPICallBuilder * (NSString *type) { + [self setValue:type forParameter:NSStringFromSelector(_cmd)]; return self; }; } diff --git a/PubNub/Data/Builders/API Call/History/PNHistoryAPICallBuilder.h b/PubNub/Data/Builders/API Call/History/PNHistoryAPICallBuilder.h index aa875a3da..2cbd6ed8a 100644 --- a/PubNub/Data/Builders/API Call/History/PNHistoryAPICallBuilder.h +++ b/PubNub/Data/Builders/API Call/History/PNHistoryAPICallBuilder.h @@ -121,6 +121,22 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, readonly, strong) PNHistoryAPICallBuilder * (^includeMessageType)(BOOL includeMessageType); +/** + * @brief Events' user-provided type presence flag. + * + * @note Available only when message fetched for multiple channels or should include message actions. + * @note Each fetched entry will contain published data under 'message' key and published message + * \c message \c type will be available under 'type' key. + * + * @param includeType Whether user-provided type should be included in response or not. + * By default set to: \b YES. + * + * @return API call configuration builder. + * + * @since 5.2.0 + */ +@property (nonatomic, readonly, strong) PNHistoryAPICallBuilder * (^includeType)(BOOL includeType); + /** * @brief Events' space presence flag. * diff --git a/PubNub/Data/Builders/API Call/History/PNHistoryAPICallBuilder.m b/PubNub/Data/Builders/API Call/History/PNHistoryAPICallBuilder.m index b97af1c83..792327055 100644 --- a/PubNub/Data/Builders/API Call/History/PNHistoryAPICallBuilder.m +++ b/PubNub/Data/Builders/API Call/History/PNHistoryAPICallBuilder.m @@ -76,6 +76,13 @@ @implementation PNHistoryAPICallBuilder }; } +- (PNHistoryAPICallBuilder * _Nonnull (^)(BOOL includeType))includeType { + return ^PNHistoryAPICallBuilder * (BOOL includeType) { + [self setValue:@(includeType) forParameter:NSStringFromSelector(_cmd)]; + return self; + }; +} + - (PNHistoryAPICallBuilder * _Nonnull (^)(BOOL includeSpaceId))includeSpaceId { return ^PNHistoryAPICallBuilder * (BOOL includeSpaceId) { [self setValue:@(includeSpaceId) forParameter:NSStringFromSelector(_cmd)]; diff --git a/PubNub/Data/Builders/API Call/Publish/PNPublishAPICallBuilder.h b/PubNub/Data/Builders/API Call/Publish/PNPublishAPICallBuilder.h index c4ac94744..5794b221b 100644 --- a/PubNub/Data/Builders/API Call/Publish/PNPublishAPICallBuilder.h +++ b/PubNub/Data/Builders/API Call/Publish/PNPublishAPICallBuilder.h @@ -4,7 +4,7 @@ #pragma mark Class forward -@class PNMessageType, PNSpaceId; +@class PNSpaceId; NS_ASSUME_NONNULL_BEGIN @@ -64,13 +64,13 @@ NS_ASSUME_NONNULL_BEGIN /** * @brief Type of message which will be published. * - * @param type Custom type for published message. + * @param type User-provided type for published message. * * @return API call configuration builder. * * @version 5.2.0 */ -@property (nonatomic, readonly, strong) PNPublishAPICallBuilder * (^messageType)(PNMessageType *type); +@property (nonatomic, readonly, strong) PNPublishAPICallBuilder * (^type)(NSString *type); /** * @brief Message metadata addition block. diff --git a/PubNub/Data/Builders/API Call/Publish/PNPublishAPICallBuilder.m b/PubNub/Data/Builders/API Call/Publish/PNPublishAPICallBuilder.m index 09d4beaa2..93fb2b28c 100644 --- a/PubNub/Data/Builders/API Call/Publish/PNPublishAPICallBuilder.m +++ b/PubNub/Data/Builders/API Call/Publish/PNPublishAPICallBuilder.m @@ -41,9 +41,9 @@ @implementation PNPublishAPICallBuilder }; } -- (PNPublishAPICallBuilder * (^)(PNMessageType *messageType))messageType { - return ^PNPublishAPICallBuilder * (PNMessageType *messageType) { - [self setValue:messageType forParameter:NSStringFromSelector(_cmd)]; +- (PNPublishAPICallBuilder * (^)(NSString *messageType))type { + return ^PNPublishAPICallBuilder * (NSString *type) { + [self setValue:type forParameter:NSStringFromSelector(_cmd)]; return self; }; } diff --git a/PubNub/Data/Builders/API Call/Publish/PNPublishFileMessageAPICallBuilder.h b/PubNub/Data/Builders/API Call/Publish/PNPublishFileMessageAPICallBuilder.h index d409807f5..785f274f9 100644 --- a/PubNub/Data/Builders/API Call/Publish/PNPublishFileMessageAPICallBuilder.h +++ b/PubNub/Data/Builders/API Call/Publish/PNPublishFileMessageAPICallBuilder.h @@ -4,7 +4,7 @@ #pragma mark Class forward -@class PNMessageType, PNSpaceId; +@class PNSpaceId; NS_ASSUME_NONNULL_BEGIN @@ -77,13 +77,13 @@ NS_ASSUME_NONNULL_BEGIN /** * @brief Type of message which will be published. * - * @param type Custom type for published message. + * @param type User-provided type for published message. * * @return API call configuration builder. * * @version 5.2.0 */ -@property (nonatomic, readonly, strong) PNPublishFileMessageAPICallBuilder * (^messageType)(PNMessageType *type); +@property (nonatomic, readonly, strong) PNPublishFileMessageAPICallBuilder * (^type)(NSString *type); /** * @brief Message metadata. diff --git a/PubNub/Data/Builders/API Call/Publish/PNPublishFileMessageAPICallBuilder.m b/PubNub/Data/Builders/API Call/Publish/PNPublishFileMessageAPICallBuilder.m index 72692341b..5e313e4fd 100644 --- a/PubNub/Data/Builders/API Call/Publish/PNPublishFileMessageAPICallBuilder.m +++ b/PubNub/Data/Builders/API Call/Publish/PNPublishFileMessageAPICallBuilder.m @@ -64,9 +64,9 @@ @implementation PNPublishFileMessageAPICallBuilder }; } -- (PNPublishFileMessageAPICallBuilder * (^)(PNMessageType *messageType))messageType { - return ^PNPublishFileMessageAPICallBuilder * (PNMessageType *messageType) { - [self setValue:messageType forParameter:NSStringFromSelector(_cmd)]; +- (PNPublishFileMessageAPICallBuilder * (^)(NSString *type))type { + return ^PNPublishFileMessageAPICallBuilder * (NSString *type) { + [self setValue:type forParameter:NSStringFromSelector(_cmd)]; return self; }; } diff --git a/PubNub/Data/Builders/API Call/Publish/PNPublishSizeAPICallBuilder.h b/PubNub/Data/Builders/API Call/Publish/PNPublishSizeAPICallBuilder.h index 244afafe6..490f1f59c 100644 --- a/PubNub/Data/Builders/API Call/Publish/PNPublishSizeAPICallBuilder.h +++ b/PubNub/Data/Builders/API Call/Publish/PNPublishSizeAPICallBuilder.h @@ -2,6 +2,11 @@ #import "PNStructures.h" +#pragma mark Class forward + +@class PNSpaceId; + + NS_ASSUME_NONNULL_BEGIN #pragma mark Interface declaration @@ -29,6 +34,17 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, readonly, strong) PNPublishSizeAPICallBuilder * (^channel)(NSString *channel); +/** + * @brief Target space identifier name. + * + * @param spaceId Identifier of the space to which signal should be published. + * + * @return API call configuration builder. + * + * @version 5.2.0 + */ +@property (nonatomic, readonly, strong) PNPublishSizeAPICallBuilder * (^spaceId)(PNSpaceId *spaceId); + /** * @brief Message payload addition block. * @@ -44,6 +60,17 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, readonly, strong) PNPublishSizeAPICallBuilder * (^message)(id message); +/** + * @brief Type of signal which will be published. + * + * @param type User-provided type for published signal. + * + * @return API call configuration builder. + * + * @version 5.2.0 + */ +@property (nonatomic, readonly, strong) PNPublishSizeAPICallBuilder * (^type)(NSString *type); + /** * @brief Message metadata addition block. * diff --git a/PubNub/Data/Builders/API Call/Publish/PNPublishSizeAPICallBuilder.m b/PubNub/Data/Builders/API Call/Publish/PNPublishSizeAPICallBuilder.m index 5a031b655..421971b58 100644 --- a/PubNub/Data/Builders/API Call/Publish/PNPublishSizeAPICallBuilder.m +++ b/PubNub/Data/Builders/API Call/Publish/PNPublishSizeAPICallBuilder.m @@ -20,21 +20,33 @@ @implementation PNPublishSizeAPICallBuilder #pragma mark - Configuration - (PNPublishSizeAPICallBuilder * (^)(NSString *channel))channel { - return ^PNPublishSizeAPICallBuilder * (NSString *channel) { [self setValue:channel forParameter:NSStringFromSelector(_cmd)]; return self; }; } +- (PNPublishSizeAPICallBuilder * _Nonnull (^)(PNSpaceId *spaceId))spaceId { + return ^PNPublishSizeAPICallBuilder * (PNSpaceId *spaceId) { + [self setValue:spaceId forParameter:NSStringFromSelector(_cmd)]; + return self; + }; +} + - (PNPublishSizeAPICallBuilder * (^)(id message))message { - return ^PNPublishSizeAPICallBuilder * (id message) { [self setValue:message forParameter:NSStringFromSelector(_cmd)]; return self; }; } +- (PNPublishSizeAPICallBuilder * _Nonnull (^)(NSString *type))type { + return ^PNPublishSizeAPICallBuilder * (NSString *type) { + [self setValue:type forParameter:NSStringFromSelector(_cmd)]; + return self; + }; +} + - (PNPublishSizeAPICallBuilder * (^)(NSDictionary *metadata))metadata { return ^PNPublishSizeAPICallBuilder * (NSDictionary *metadata) { diff --git a/PubNub/Data/Builders/API Call/Publish/PNSignalAPICallBuilder.h b/PubNub/Data/Builders/API Call/Publish/PNSignalAPICallBuilder.h index b6771f736..121241480 100644 --- a/PubNub/Data/Builders/API Call/Publish/PNSignalAPICallBuilder.h +++ b/PubNub/Data/Builders/API Call/Publish/PNSignalAPICallBuilder.h @@ -4,7 +4,8 @@ #pragma mark Class forward -@class PNMessageType, PNSpaceId; +@class PNSpaceId; + NS_ASSUME_NONNULL_BEGIN @@ -59,13 +60,13 @@ NS_ASSUME_NONNULL_BEGIN /** * @brief Type of signal which will be published. * - * @param type Custom type for published signal. + * @param type User-provided type for published signal. * * @return API call configuration builder. * * @version 5.2.0 */ -@property (nonatomic, readonly, strong) PNSignalAPICallBuilder * (^messageType)(PNMessageType *type); +@property (nonatomic, readonly, strong) PNSignalAPICallBuilder * (^type)(NSString *type); #pragma mark - Execution diff --git a/PubNub/Data/Builders/API Call/Publish/PNSignalAPICallBuilder.m b/PubNub/Data/Builders/API Call/Publish/PNSignalAPICallBuilder.m index 2874d26e5..7505c94f4 100644 --- a/PubNub/Data/Builders/API Call/Publish/PNSignalAPICallBuilder.m +++ b/PubNub/Data/Builders/API Call/Publish/PNSignalAPICallBuilder.m @@ -44,9 +44,9 @@ @implementation PNSignalAPICallBuilder }; } -- (PNSignalAPICallBuilder * (^)(PNMessageType * messageType))messageType { - return ^PNSignalAPICallBuilder * (PNMessageType *messageType) { - [self setValue:messageType forParameter:NSStringFromSelector(_cmd)]; +- (PNSignalAPICallBuilder * (^)(NSString * type))type { + return ^PNSignalAPICallBuilder * (NSString *type) { + [self setValue:type forParameter:NSStringFromSelector(_cmd)]; return self; }; } diff --git a/PubNub/Data/Managers/PNSubscriber.m b/PubNub/Data/Managers/PNSubscriber.m index 13e78262c..7435e74fd 100644 --- a/PubNub/Data/Managers/PNSubscriber.m +++ b/PubNub/Data/Managers/PNSubscriber.m @@ -1532,7 +1532,7 @@ - (void)handleLiveFeedEvents:(PNSubscribeStatus *)status forInitialSubscription: [self handleNewPresenceEvent:((PNPresenceEventResult *)eventResultObject)]; } else { PNEnvelopeInformation *envelope = event[@"envelope"]; - PNServiceMessageType messageType = envelope.pubNubMessageType; + PNServiceMessageType messageType = envelope.messageType; if (messageType == PNObjectMessageType) { [self handleNewObjectsEvent:eventResultObject]; @@ -1741,7 +1741,7 @@ - (void)deDuplicateMessages:(NSMutableArray *)events { NSMutableIndexSet *duplicateMessagesIndices = [NSMutableIndexSet indexSet]; [events enumerateObjectsUsingBlock:^(NSDictionary *event, NSUInteger eventIdx, BOOL *eventsEnumeratorStop) { - PNServiceMessageType messageType = ((PNEnvelopeInformation *)event[@"envelope"]).pubNubMessageType; + PNServiceMessageType messageType = ((PNEnvelopeInformation *)event[@"envelope"]).messageType; BOOL isMessageEvent = (messageType != PNFileMessageType && messageType != PNObjectMessageType && messageType != PNMessageActionType); diff --git a/PubNub/Data/Models/PNMessageType+Private.h b/PubNub/Data/Models/PNMessageType+Private.h deleted file mode 100644 index 6c63d9fe2..000000000 --- a/PubNub/Data/Models/PNMessageType+Private.h +++ /dev/null @@ -1,38 +0,0 @@ -#import "PNMessageType.h" -#import "PNPrivateStructures.h" - - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark Interface extension declaration - -/** - * @brief Extension for public interface for parsers support. - * - * @author Serhii Mamontov - * @version 5.2.0 - * @since 5.2.0 - * @copyright © 2010-2022 PubNub Inc. All Rights Reserved. - */ -@interface PNMessageType (Private) - - -#pragma mark - Initialization and configuration - -/** - * @brief Create and configure message type based on type provided by \b PubNub and user. - * - * @param userMessageType Custom message type which should be used when publish message. - * @param pubNubMessageType One of pre-defined message / event types. - * - * @return Configured and ready to use message type instance. - */ -+ (instancetype)messageTypeFromString:(NSString *)userMessageType - pubNubMessageType:(PNServiceMessageType)pubNubMessageType; - -#pragma mark - - - -@end - -NS_ASSUME_NONNULL_END diff --git a/PubNub/Data/Models/PNMessageType.h b/PubNub/Data/Models/PNMessageType.h deleted file mode 100644 index e18f830fa..000000000 --- a/PubNub/Data/Models/PNMessageType.h +++ /dev/null @@ -1,76 +0,0 @@ -#import - - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark Interface declaration - -/** - * @brief Published message representation model. - * - * @discussion This type let identify message received from subscriber later. - * There is five types which is set by \b PubNub service depending from used API endpoint: - * - \c message - * - \c signal - * - \c object - * - \c messageAction - * - \c file - * - * Additionally it is possible to specify custom type for published message using \b PNMessageType method - * - * @author Serhii Mamontov - * @version 5.2.0 - * @since 5.2.0 - * @copyright © 2010-2022 PubNub Inc. All Rights Reserved. - */ -@interface PNMessageType : NSObject - - -#pragma mark - Information - -/** - * @brief One of types associated with message when it has been published. - * - * @discussion This property may store \b PubNub defined types (like: message, signal, file, object, messageAction - */ -@property(nonatomic, readonly, copy) NSString *value; - - -#pragma mark - Initialization and configuration - -/** - * @brief Create and configure message type instance. - * - * @param type Custom message type which should be used when publish message. - * - * @return Configured and ready to use message type instance. - */ -+ (instancetype)messageTypeFromString:(NSString *)type; - -/** - * @brief Initialize message type instance. - * - * @note This method can't be used directly and will throw an exception. - * - * @return Message type instance. - */ -- (nullable instancetype)init NS_UNAVAILABLE; - - -#pragma mark - Helper - -/** - * @brief Check whether receiving message type is equal to another instance. - * - * @param otherMessageType Second instance against which check should be done. - * - * @return \c YES if \c otherMessageType is equal to receiver. - */ -- (BOOL)isEqualToMessageType:(PNMessageType *)otherMessageType; - -#pragma mark - - - -@end - -NS_ASSUME_NONNULL_END diff --git a/PubNub/Data/Models/PNMessageType.m b/PubNub/Data/Models/PNMessageType.m deleted file mode 100644 index cc9935be9..000000000 --- a/PubNub/Data/Models/PNMessageType.m +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @author Serhii Mamontov - * @version 5.2.0 - * @since 5.2.0 - * @copyright © 2010-2022 PubNub Inc. All Rights Reserved. - */ -#import "PNMessageType+Private.h" - - -NS_ASSUME_NONNULL_BEGIN - -#pragma mark Protected interface declaration - -@interface PNMessageType () - -/** - * @brief One of types associated with message when it has been published. - * - * @discussion This property may store \b PubNub defined types (like: message, signal, file, object, messageAction - */ -@property(nonatomic, copy) NSString *value; - - -#pragma mark - Initialization and configuration - -/** - * @brief Create and configure instance from actual value. - * - * @param value Custom user type of stringified \b PubNub provided type. - */ -- (instancetype)initWithValueFromString:(NSString *)value NS_DESIGNATED_INITIALIZER; - - -#pragma mark - Helper - -/** - * @brief Transform provided data to string. - * - * @param userType User-provided type which should be used for message type. - * @param pnType \b PubNub provided message type which should be stringified. - * - * @return Proper message type which will be used by user and publish endpoints. - */ -+ (NSString *)valueFromUserType:(nullable NSString *)userType - pubNubMessageType:(PNServiceMessageType)pnType; - -#pragma mark - - - -@end - -NS_ASSUME_NONNULL_END - - -#pragma mark - Interface implementation - -@implementation PNMessageType - - -#pragma mark - Initialization and configuration - -+ (instancetype)messageTypeFromString:(NSString *)type { - return [self messageTypeFromString:type pubNubMessageType:PNRegularMessageType]; -} - -+ (instancetype)messageTypeFromString:(NSString *)userType pubNubMessageType:(PNServiceMessageType)pnType { - return [[self alloc] initWithValueFromString:[self valueFromUserType:userType pubNubMessageType:pnType]]; -} - -- (instancetype)init { - NSDictionary *errorInformation = @{ NSLocalizedRecoverySuggestionErrorKey: @"Use provided constructor" }; - @throw [NSException exceptionWithName:@"PNInterfaceNotAvailable" - reason:@"+new or -init methods unavailable." - userInfo:errorInformation]; - - return nil; -} - -- (instancetype)initWithValueFromString:(NSString *)value { - if ((self = [super init])) { - _value = [value copy]; - } - - return self; -} - - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - return [[PNMessageType alloc] initWithValueFromString:self.value]; -} - - -#pragma mark - Helper - -- (BOOL)isEqual:(id)other { - return other && [other isKindOfClass:[self class]] ? [self isEqualToMessageType:other] : NO; -} - -- (BOOL)isEqualToMessageType:(PNMessageType *)otherMessageType { - return [self.value isEqualToString:otherMessageType.value]; -} - -+ (NSString *)valueFromUserType:(NSString *)userMessageType pubNubMessageType:(PNServiceMessageType)pubNubMessageType { - static NSArray *_pubNubMessageTypeMap; - static dispatch_once_t onceToken; - - dispatch_once(&onceToken, ^{ - _pubNubMessageTypeMap = @[@"pn_message", @"pn_signal", @"pn_object", @"pn_messageAction", @"pn_file"]; - }); - - return userMessageType.length ? userMessageType : _pubNubMessageTypeMap[pubNubMessageType]; -} - -#pragma mark - - - -@end diff --git a/PubNub/Data/PNEnvelopeInformation.h b/PubNub/Data/PNEnvelopeInformation.h index 53ce05adf..c48596cb9 100644 --- a/PubNub/Data/PNEnvelopeInformation.h +++ b/PubNub/Data/PNEnvelopeInformation.h @@ -4,7 +4,7 @@ #pragma mark Class forward -@class PNMessageType, PNSpaceId; +@class PNSpaceId; /** @@ -53,14 +53,14 @@ * * @since 5.2.0 */ -@property (atomic, readonly, assign) PNServiceMessageType pubNubMessageType; +@property (atomic, readonly, assign) PNServiceMessageType messageType; /** - * @brief Object's message type. + * @brief Object's user-provided type. * * @since 5.2.0 */ -@property (nonatomic, nullable, readonly, strong) PNMessageType *messageType; +@property (nonatomic, nullable, readonly, strong) NSString *type; /** * @brief Identifier of space from which message has been received. diff --git a/PubNub/Data/PNEnvelopeInformation.m b/PubNub/Data/PNEnvelopeInformation.m index da9624081..e0b209a9c 100644 --- a/PubNub/Data/PNEnvelopeInformation.m +++ b/PubNub/Data/PNEnvelopeInformation.m @@ -5,7 +5,6 @@ @copyright © 2010-2019 PubNub Inc. */ #import "PNEnvelopeInformation.h" -#import "PNMessageType+Private.h" #import "PNSpaceId.h" #import "PNJSON.h" @@ -45,10 +44,10 @@ /** * @brief Key under which stored \b PubNub defined object's message type. */ - __unsafe_unretained NSString *pubNubMessageTypeKey; + __unsafe_unretained NSString *messageTypeKey; /** - * @brief Key under which stored user-defined object's message type. + * @brief Key under which stored user-provided object's message type. */ __unsafe_unretained NSString *userMessageTypeKey; @@ -84,7 +83,7 @@ .senderIdentifier = @"i", .sequenceNumber = @"s", .subscribeKey = @"k", - .pubNubMessageTypeKey = @"e", + .messageTypeKey = @"e", .userMessageTypeKey = @"mt", .spaceIdKey = @"si", .replicationMap = @"r", @@ -108,8 +107,8 @@ @interface PNEnvelopeInformation () @property (nonatomic, copy) NSString *senderIdentifier; @property (nonatomic, copy) NSNumber *sequenceNumber; @property (nonatomic, copy) NSString *subscribeKey; -@property (atomic, assign) PNServiceMessageType pubNubMessageType; -@property (nonatomic, nullable, strong) PNMessageType *messageType; +@property (atomic, assign) PNServiceMessageType messageType; +@property (nonatomic, nullable, strong) NSString *type; @property (nonatomic, nullable, strong) PNSpaceId *spaceId; @property (nonatomic, copy) NSNumber *replicationMap; @property (nonatomic, copy) NSNumber *eatAfterReading; @@ -159,9 +158,8 @@ - (nonnull instancetype)initWithPayload:(nonnull NSDictionary *)payload { _metadata = [payload[PNDebugEventEnvelope.metadata] copy]; _waypoints = [payload[PNDebugEventEnvelope.waypoints] copy]; - _pubNubMessageType = ((NSNumber *)payload[PNDebugEventEnvelope.pubNubMessageTypeKey]).unsignedIntegerValue; - NSString *userMessageType = payload[PNDebugEventEnvelope.userMessageTypeKey]; - _messageType = [PNMessageType messageTypeFromString:userMessageType pubNubMessageType:_pubNubMessageType]; + _messageType = ((NSNumber *)payload[PNDebugEventEnvelope.messageTypeKey]).unsignedIntegerValue; + _type = payload[PNDebugEventEnvelope.userMessageTypeKey]; NSString *spaceId = payload[PNDebugEventEnvelope.spaceIdKey]; if (spaceId) { @@ -186,7 +184,8 @@ - (NSDictionary *)dictionaryRepresentation { @"Client Identifier": (self.senderIdentifier?: @""), @"Sequence number": (self.sequenceNumber?: @""), @"Subscribe key": (self.subscribeKey?: @""), - @"Message type": (self.messageType.value ?: @(self.pubNubMessageType)), + @"Message type": @(self.messageType), + @"User-provided type": (self.type ?: @""), @"Replication map": (self.replicationMap?: @""), @"Eat after reading": (self.eatAfterReading ? (self.shouldEatAfterReading ? @"YES" : @"NO") : @""), @"Metadata": (self.metadata ? [PNJSON JSONStringFrom:self.metadata withError:nil] : @""), diff --git a/PubNub/Data/Service Objects/PNResult.m b/PubNub/Data/Service Objects/PNResult.m index 4f4195be7..511cbd340 100644 --- a/PubNub/Data/Service Objects/PNResult.m +++ b/PubNub/Data/Service Objects/PNResult.m @@ -203,11 +203,10 @@ - (NSDictionary *)dictionaryRepresentation { - (NSDictionary *)dictionaryRepresentationFromDictionary:(NSDictionary *)dictionary { NSMutableDictionary *representation = [NSMutableDictionary new]; - Class messageTypeClass = NSClassFromString(@"PNMessageType"); Class spaceIdClass = NSClassFromString(@"PNSpaceId"); [dictionary enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) { - if ([obj isKindOfClass:messageTypeClass] || [obj isKindOfClass:spaceIdClass]) { + if ([obj isKindOfClass:spaceIdClass]) { representation[key] = [obj valueForKey:@"value"]; } else if ([[obj class] isSubclassOfClass:[NSDictionary class]]) { representation[key] = [self dictionaryRepresentationFromDictionary:obj]; @@ -223,11 +222,10 @@ - (NSDictionary *)dictionaryRepresentationFromDictionary:(NSDictionary *)diction - (NSArray *)arrayRepresentationFromArray:(NSArray *)array { NSMutableArray *representation = [NSMutableArray new]; - Class messageTypeClass = NSClassFromString(@"PNMessageType"); Class spaceIdClass = NSClassFromString(@"PNSpaceId"); [array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj isKindOfClass:messageTypeClass] || [obj isKindOfClass:spaceIdClass]) { + if ([obj isKindOfClass:spaceIdClass]) { if ([obj valueForKey:@"value"]) [representation addObject:[obj valueForKey:@"value"]]; } else if ([[obj class] isSubclassOfClass:[NSDictionary class]]) { [representation addObject:[self dictionaryRepresentationFromDictionary:obj]]; diff --git a/PubNub/Data/Service Objects/PNSubscribeStatus.h b/PubNub/Data/Service Objects/PNSubscribeStatus.h index 754c04202..b66141ee7 100644 --- a/PubNub/Data/Service Objects/PNSubscribeStatus.h +++ b/PubNub/Data/Service Objects/PNSubscribeStatus.h @@ -4,7 +4,7 @@ #pragma mark Class forward -@class PNMessageType, PNSpaceId; +@class PNSpaceId; NS_ASSUME_NONNULL_BEGIN @@ -51,11 +51,11 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly, strong) NSNumber *timetoken; /** - * @brief Type of message which has been published. + * @brief User-provided type of message which has been published. * * @since 5.2.0 */ -@property (nonatomic, nullable, readonly, strong) PNMessageType *messageType; +@property (nonatomic, nullable, readonly, strong) NSString *type; /** * @brief Stores reference on metadata information which has been passed along with received event. diff --git a/PubNub/Data/Service Objects/PNSubscribeStatus.m b/PubNub/Data/Service Objects/PNSubscribeStatus.m index 012dece3c..d5d973540 100644 --- a/PubNub/Data/Service Objects/PNSubscribeStatus.m +++ b/PubNub/Data/Service Objects/PNSubscribeStatus.m @@ -26,8 +26,8 @@ - (PNSpaceId *)spaceId { return self.envelope.spaceId; } -- (PNMessageType *)messageType { - return self.envelope.messageType; +- (NSString *)type { + return self.envelope.type; } - (NSString *)subscription { diff --git a/PubNub/Network/Parsers/PNHistoryParser.m b/PubNub/Network/Parsers/PNHistoryParser.m index 03627d572..be3753758 100644 --- a/PubNub/Network/Parsers/PNHistoryParser.m +++ b/PubNub/Network/Parsers/PNHistoryParser.m @@ -5,7 +5,7 @@ * @copyright © 2010-2019 PubNub, Inc. */ #import "PNHistoryParser.h" -#import "PNMessageType+Private.h" +#import "PNPrivateStructures.h" #import "PubNub+CorePrivate.h" #import "PNSpaceId.h" #import "PNConstants.h" @@ -236,10 +236,12 @@ + (NSMutableDictionary *)processedMessagesFrom:(NSArray *)messages if (timeToken || metadata || actions || pubNubMessageType || userMessageType || spaceId || senderUUID) { NSMutableDictionary *messageWithInfo = [@{ @"message": message } mutableCopy]; - if ([pubNubMessageType isKindOfClass:[NSNumber class]] || - [userMessageType isKindOfClass:[NSString class]]) { - messageWithInfo[@"messageType"] = [PNMessageType messageTypeFromString:userMessageType - pubNubMessageType:pubNubMessageType.unsignedIntValue]; + if ([pubNubMessageType isKindOfClass:[NSNumber class]]) { + messageWithInfo[@"messageType"] = pubNubMessageType; + } + + if ([userMessageType isKindOfClass:[NSString class]]) { + messageWithInfo[@"type"] = userMessageType; } if (spaceId) { diff --git a/PubNub/Network/Parsers/PNSubscribeParser.m b/PubNub/Network/Parsers/PNSubscribeParser.m index d204273cc..bc2a5cd9f 100644 --- a/PubNub/Network/Parsers/PNSubscribeParser.m +++ b/PubNub/Network/Parsers/PNSubscribeParser.m @@ -419,7 +419,7 @@ + (NSMutableDictionary *)eventFromData:(NSDictionary *)data event[@"subscription"] = (subscriptionMatch ?: channel); event[@"channel"] = channel; - PNServiceMessageType messageType = ((PNEnvelopeInformation *)event[@"envelope"]).pubNubMessageType; + PNServiceMessageType messageType = ((PNEnvelopeInformation *)event[@"envelope"]).messageType; BOOL isEncryptionSupported = messageType == PNRegularMessageType || messageType == PNFileMessageType; diff --git a/PubNub/Network/Requests/Files/PNSendFileRequest.h b/PubNub/Network/Requests/Files/PNSendFileRequest.h index 80e700ac0..3a3035212 100644 --- a/PubNub/Network/Requests/Files/PNSendFileRequest.h +++ b/PubNub/Network/Requests/Files/PNSendFileRequest.h @@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark Class forward -@class PNSpaceId, PNMessageType; +@class PNSpaceId; #pragma mark - Interface declaration @@ -72,11 +72,11 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, nullable, strong) id message; /** - * @brief Custom type with which message should be published. + * @brief User-provided type with which message should be published. * * @since 5.2.0 */ -@property (nonatomic, nullable, strong) PNMessageType *messageType; +@property (nonatomic, nullable, strong) NSString *type; /** * @brief Name which should be used to store uploaded data. diff --git a/PubNub/Network/Requests/Publish/PNBasePublishRequest.h b/PubNub/Network/Requests/Publish/PNBasePublishRequest.h index e6c5f51af..aced50f66 100644 --- a/PubNub/Network/Requests/Publish/PNBasePublishRequest.h +++ b/PubNub/Network/Requests/Publish/PNBasePublishRequest.h @@ -4,7 +4,7 @@ #pragma mark Class forward -@class PNMessageType, PNSpaceId; +@class PNSpaceId; NS_ASSUME_NONNULL_BEGIN @@ -60,11 +60,11 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, nullable, strong) id message; /** - * @brief Custom type with which message should be published. + * @brief User-provided type with which message should be published. * * @since 5.2.0 */ -@property (nonatomic, nullable, strong) PNMessageType *messageType; +@property (nonatomic, nullable, strong) NSString *type; /** * @brief How long message should be stored in channel's storage. Pass \b 0 store message according to retention. diff --git a/PubNub/Network/Requests/Publish/PNBasePublishRequest.m b/PubNub/Network/Requests/Publish/PNBasePublishRequest.m index 259dfe20b..111a42457 100644 --- a/PubNub/Network/Requests/Publish/PNBasePublishRequest.m +++ b/PubNub/Network/Requests/Publish/PNBasePublishRequest.m @@ -6,7 +6,6 @@ */ #import "PNBasePublishRequest+Private.h" #import "PNRequest+Private.h" -#import "PNMessageType.h" #import "PNSpaceId.h" #import "PNHelpers.h" #import "PNAES.h" @@ -120,8 +119,8 @@ - (PNRequestParameters *)requestParameters { [parameters addQueryParameter:self.spaceId.value forFieldName:@"space-id"]; } - if (self.messageType) { - [parameters addQueryParameter:self.messageType.value forFieldName:@"type"]; + if (self.type) { + [parameters addQueryParameter:self.type forFieldName:@"type"]; } parameters.POSTBodyCompressed = self.shouldCompress; diff --git a/Tests/Tests/Contract/Steps/Files/PNFilesContractTestSteps.m b/Tests/Tests/Contract/Steps/Files/PNFilesContractTestSteps.m index 2f3ff5163..2217a98ed 100644 --- a/Tests/Tests/Contract/Steps/Files/PNFilesContractTestSteps.m +++ b/Tests/Tests/Contract/Steps/Files/PNFilesContractTestSteps.m @@ -85,7 +85,7 @@ - (void)setup { }]; }); - When(@"^I send a file with '(.+)' space id and '(.+)' message type$", ^(NSArray *args, NSDictionary *userInfo) { + When(@"^I send a file with '(.+)' space id and '(.+)' type$", ^(NSArray *args, NSDictionary *userInfo) { XCTAssertEqual(args.count, 2); NSString *messageType = args.lastObject; NSString *spaceId = args.firstObject; @@ -96,7 +96,7 @@ - (void)setup { self.client.files() .sendFile(@"test", @"name.txt") .data([@"test file data" dataUsingEncoding:NSUTF8StringEncoding]) - .messageType([PNMessageType messageTypeFromString:messageType]) + .type(messageType) .spaceId([PNSpaceId spaceIdFromString:spaceId]) .performWithCompletion(^(PNSendFileStatus *status) { [self storeRequestStatus:status]; diff --git a/Tests/Tests/Contract/Steps/History/PNHistoryContractTestSteps.m b/Tests/Tests/Contract/Steps/History/PNHistoryContractTestSteps.m index d1315baca..f9e4609bd 100644 --- a/Tests/Tests/Contract/Steps/History/PNHistoryContractTestSteps.m +++ b/Tests/Tests/Contract/Steps/History/PNHistoryContractTestSteps.m @@ -30,30 +30,35 @@ - (void)setup { }]; }); - Match(@[@"And"], @"^history response contains messages (with|without) ('(.*)' and '(.*)' )?message types$", + Match(@[@"And"], @"^history response contains messages (with|without) ('(.*)' and '(.*)' )?(message )?types$", ^(NSArray *args, NSDictionary *userInfo) { XCTAssertGreaterThan(args.count, 0); + BOOL pubNubMessageType = [args containsObject:@"message "]; NSString *inclusionFlag = args.firstObject; PNHistoryResult *result = (PNHistoryResult *)[self lastResult]; XCTAssertNotNil(result); NSArray *messages = result.data.channels.allValues.firstObject; XCTAssertGreaterThan(messages.count, 0); - NSArray *receivedMessageTypes = [messages valueForKeyPath:@"messageType.value"]; - NSMutableArray *filteredReceivedMessageTypes = [NSMutableArray arrayWithArray:receivedMessageTypes]; - [filteredReceivedMessageTypes removeObjectIdenticalTo:[NSNull null]]; + NSArray *receivedTypes = [messages valueForKeyPath:(pubNubMessageType ? @"messageType" : @"type")]; + NSMutableArray *filteredReceivedTypes = [NSMutableArray arrayWithArray:receivedTypes]; + [filteredReceivedTypes removeObjectIdenticalTo:[NSNull null]]; - XCTAssertFalse([inclusionFlag isEqual:@"with"] && filteredReceivedMessageTypes.count == 0); - XCTAssertFalse([inclusionFlag isEqual:@"without"] && filteredReceivedMessageTypes.count > 0); + XCTAssertFalse([inclusionFlag isEqual:@"with"] && filteredReceivedTypes.count == 0); + XCTAssertFalse([inclusionFlag isEqual:@"without"] && filteredReceivedTypes.count > 0); if (args.count > 1) { - SEL compare = @selector(caseInsensitiveCompare:); - NSArray *expectedMessageTypes = [[args subarrayWithRange:NSMakeRange(2, 2)] sortedArrayUsingSelector:compare]; - NSArray *receivedMessageTypes = [filteredReceivedMessageTypes sortedArrayUsingSelector:compare]; + SEL compare = pubNubMessageType ? @selector(compare:) : @selector(caseInsensitiveCompare:); + NSArray *expectedMessageTypes = [args subarrayWithRange:NSMakeRange(2, 2)]; + if (pubNubMessageType) { + expectedMessageTypes = [expectedMessageTypes valueForKey:@"intValue"]; + } + expectedMessageTypes = [expectedMessageTypes sortedArrayUsingSelector:compare]; + NSArray *receivedMessageTypes = [filteredReceivedTypes sortedArrayUsingSelector:compare]; XCTAssertEqualObjects(receivedMessageTypes, expectedMessageTypes); } else { XCTAssertEqual([inclusionFlag isEqual:@"with"] ? messages.count : 0, - filteredReceivedMessageTypes.count); + filteredReceivedTypes.count); } }); @@ -115,11 +120,11 @@ - (void)setup { ^(NSArray *args, NSDictionary *userInfo) { XCTAssertEqual(args.count, 3); self.testedFeatureType = PNHistoryWithActionsOperation; - BOOL includeMessageType = YES; BOOL includeSpaceId = NO; + BOOL includeType = YES; - if ([args.firstObject isEqual:@"includeMessageType"]) { - includeMessageType = [args[1] isEqual:@"true"]; + if ([args.firstObject isEqual:@"includeType"]) { + includeType = [args[1] isEqual:@"true"]; } else if ([args.firstObject isEqual:@"includeSpaceId"]) { includeSpaceId = [args[1] isEqual:@"true"]; } @@ -127,7 +132,7 @@ - (void)setup { [self callCodeSynchronously:^(dispatch_block_t completion) { self.client.history() .channels(@[args[2]]) - .includeMessageType(includeMessageType) + .includeType(includeType) .includeSpaceId(includeSpaceId) .performWithCompletion(^(PNHistoryResult *result, PNErrorStatus *status) { [self storeRequestResult:result]; diff --git a/Tests/Tests/Contract/Steps/Publish/PNPublishContractTestSteps.m b/Tests/Tests/Contract/Steps/Publish/PNPublishContractTestSteps.m index ef8e0fc0c..9546a3c58 100644 --- a/Tests/Tests/Contract/Steps/Publish/PNPublishContractTestSteps.m +++ b/Tests/Tests/Contract/Steps/Publish/PNPublishContractTestSteps.m @@ -120,7 +120,7 @@ - (void)setup { }]; }); - When(@"^I publish message with '(.*)' space id and '(.*)' message type$", + When(@"^I publish message with '(.*)' space id and '(.*)' type$", ^(NSArray *args, NSDictionary *userInfo) { self.testedFeatureType = PNPublishOperation; @@ -128,7 +128,7 @@ - (void)setup { self.client.publish() .message(@"hello") .channel(@"test") - .messageType([PNMessageType messageTypeFromString:args.lastObject]) + .type(args.lastObject) .spaceId([PNSpaceId spaceIdFromString:args.firstObject]) .performWithCompletion(^(PNPublishStatus *status) { [self storeRequestStatus:status]; @@ -151,7 +151,7 @@ - (void)setup { }]; }); - When(@"^I send a signal with '(.*)' space id and '(.*)' message type$", + When(@"^I send a signal with '(.*)' space id and '(.*)' type$", ^(NSArray *args, NSDictionary *userInfo) { self.testedFeatureType = PNSignalOperation; @@ -159,7 +159,7 @@ - (void)setup { self.client.signal() .message(@"hello") .channel(@"test") - .messageType([PNMessageType messageTypeFromString:args.lastObject]) + .type(args.lastObject) .spaceId([PNSpaceId spaceIdFromString:args.firstObject]) .performWithCompletion(^(PNSignalStatus *status) { [self storeRequestStatus:status]; diff --git a/Tests/Tests/Integration/Files/PNFilesIntegrationTests.m b/Tests/Tests/Integration/Files/PNFilesIntegrationTests.m index 7f5df01fc..96d5d4f6b 100644 --- a/Tests/Tests/Integration/Files/PNFilesIntegrationTests.m +++ b/Tests/Tests/Integration/Files/PNFilesIntegrationTests.m @@ -3,6 +3,7 @@ * @copyright © 2010-2020 PubNub, Inc. */ #import "PNRecordableTestCase.h" +#import #import #import "NSString+PNTest.h" @@ -169,7 +170,9 @@ - (void)testItShouldSendFileFromDataAndReceiveFromHistory { XCTAssertEqual(messages.count, 1); XCTAssertNotNil(messages.firstObject[@"uuid"]); XCTAssertNotNil(messages.firstObject[@"messageType"]); - XCTAssertEqualObjects(((PNMessageType *)messages.firstObject[@"messageType"]).value, @"pn_file"); + XCTAssertNotNil(messages.firstObject[@"type"]); + XCTAssertEqualObjects(messages.firstObject[@"type"], @""); + XCTAssertEqualObjects(messages.firstObject[@"messageType"], @(PNFileMessageType)); handler(); });