Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add message type support for: publish, signal, history and subscribe #444

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
84 changes: 72 additions & 12 deletions Framework/PubNub Framework.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Framework/PubNub/PubNub.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ FOUNDATION_EXPORT const unsigned char PubNubVersionString[];
#import "PNResult.h"
#import "PNStatus.h"

// Models
#import "PNMessageType.h"
#import "PNSpaceId.h"

// API
#import "PubNub+Core.h"
#import "PubNub+MessageActions.h"
Expand Down
18 changes: 17 additions & 1 deletion PubNub/Core/PubNub+History.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ @interface PubNub (HistoryProtected)
* not.
* @param includeMessageType Whether 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.
* @param shouldIncludeMessageActions Whether event actions should be included in response or not.
Expand All @@ -61,6 +62,7 @@ - (void)historyForChannels:(BOOL)multipleChannels
reverse:(nullable NSNumber *)shouldReverseOrder
includeTimeToken:(nullable NSNumber *)shouldIncludeTimeToken
includeMessageType:(nullable NSNumber *)includeMessageType
includeSpaceId:(nullable NSNumber *)includeSpaceId
includeUUID:(nullable NSNumber *)includeUUID
includeMessageActions:(nullable NSNumber *)shouldIncludeMessageActions
includeMetadata:(nullable NSNumber *)shouldIncludeMetadata
Expand Down Expand Up @@ -153,6 +155,7 @@ @implementation PubNub (History)
NSNumber *reverse = parameters[NSStringFromSelector(@selector(reverse))];
NSNumber *includeTimeToken = parameters[NSStringFromSelector(@selector(includeTimeToken))];
NSNumber *includeMessageType = parameters[NSStringFromSelector(@selector(includeMessageType))];
NSNumber *includeSpaceId = parameters[NSStringFromSelector(@selector(includeSpaceId))];
NSNumber *includeUUID = parameters[NSStringFromSelector(@selector(includeUUID))];
NSNumber *includeMetadata = parameters[NSStringFromSelector(@selector(includeMetadata))];
NSNumber *includeActions = parameters[NSStringFromSelector(@selector(includeMessageActions))];
Expand All @@ -167,6 +170,7 @@ @implementation PubNub (History)
reverse:reverse
includeTimeToken:includeTimeToken
includeMessageType:includeMessageType
includeSpaceId:includeSpaceId
includeUUID:includeUUID
includeMessageActions:includeActions
includeMetadata:includeMetadata
Expand Down Expand Up @@ -316,6 +320,7 @@ - (void)historyForChannel:(NSString *)channel
reverse:@NO
includeTimeToken:@NO
includeMessageType:@YES
includeSpaceId:@NO
includeUUID:@YES
includeMessageActions:@(shouldIncludeMessageActions)
includeMetadata:@(shouldIncludeMetadata)
Expand Down Expand Up @@ -403,6 +408,7 @@ - (void)historyForChannel:(NSString *)channel
reverse:@(shouldReverseOrder)
includeTimeToken:@(shouldIncludeTimeToken)
includeMessageType:@YES
includeSpaceId:@NO
includeUUID:@YES
includeMessageActions:nil
includeMetadata:nil
Expand All @@ -418,6 +424,7 @@ - (void)historyForChannels:(BOOL)multipleChannels
reverse:(NSNumber *)shouldReverseOrder
includeTimeToken:(NSNumber *)shouldIncludeTimeToken
includeMessageType:(NSNumber *)includeMessageType
includeSpaceId:(NSNumber *)includeSpaceId
includeUUID:(NSNumber *)includeUUID
includeMessageActions:(NSNumber *)shouldIncludeMessageActions
includeMetadata:(NSNumber *)shouldIncludeMetadata
Expand All @@ -436,10 +443,14 @@ - (void)historyForChannels:(BOOL)multipleChannels
if (!limit || limit.unsignedIntValue == 0) {
limit = nil;
}

if (!includeMessageType) {
includeMessageType = @YES;
}

if (!includeSpaceId) {
includeSpaceId = @NO;
}

if (!includeUUID) {
includeUUID = @YES;
Expand Down Expand Up @@ -508,6 +519,10 @@ - (void)historyForChannels:(BOOL)multipleChannels
if (operation == PNHistoryWithActionsOperation || multipleChannels) {
[parameters addQueryParameter:(includeMessageType.boolValue ? @"true" : @"false")
forFieldName:@"include_message_type"];
[parameters addQueryParameter:(includeMessageType.boolValue ? @"true" : @"false")
forFieldName:@"include_type"];
[parameters addQueryParameter:(includeSpaceId.boolValue ? @"true" : @"false")
forFieldName:@"include_space_id"];
[parameters addQueryParameter:(includeUUID.boolValue ? @"true" : @"false")
forFieldName:@"include_uuid"];
}
Expand Down Expand Up @@ -569,6 +584,7 @@ - (void)historyForChannels:(BOOL)multipleChannels
reverse:shouldReverseOrder
includeTimeToken:shouldIncludeTimeToken
includeMessageType:includeMessageType
includeSpaceId:includeSpaceId
includeUUID:includeUUID
includeMessageActions:shouldIncludeMessageActions
includeMetadata:shouldIncludeMetadata
Expand Down
3 changes: 3 additions & 0 deletions PubNub/Core/PubNub+Publish.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#import "PNPublishFileMessageRequest.h"
#import "PNPublishRequest.h"

#import "PNMessageType.h"
#import "PNSpaceId.h"

#import "PNPublishFileMessageAPICallBuilder.h"
#import "PNPublishSizeAPICallBuilder.h"
#import "PNPublishAPICallBuilder.h"
Expand Down
Loading