Skip to content

Commit

Permalink
Add type and status for App Context (#464)
Browse files Browse the repository at this point in the history
feat(app-context): add `type` and `status` for App Context

Add support for `type` and `status` fields for all App Context entities: `channel`, `uuid`,
`membership`, and `member`.

feat(app-context): add `If-Match` header support

Add `If-Match` header support to set `Channel` and `UUID` metadata app context objects.
  • Loading branch information
parfeon authored Feb 27, 2025
1 parent e126f86 commit 053b156
Show file tree
Hide file tree
Showing 41 changed files with 3,246 additions and 59 deletions.
17 changes: 12 additions & 5 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
---
name: objective-c
scm: github.com/pubnub/objective-c
version: "5.7.1"
version: "5.8.0"
schema: 1
changelog:
- date: 2025-02-27
version: v5.8.0
changes:
- type: feature
text: "Add support for `type` and `status` fields for all App Context entities: `channel`, `uuid`, `membership`, and `member`."
- type: feature
text: "Add `If-Match` header support to set `Channel` and `UUID` metadata app context objects."
- date: 2025-02-03
version: v5.7.1
changes:
Expand Down Expand Up @@ -1375,7 +1382,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: PubNub.framework
location: https://github.com/pubnub/objective-c/archive/refs/tags/v5.7.1.zip
location: https://github.com/pubnub/objective-c/archive/refs/tags/v5.8.0.zip
supported-platforms:
supported-operating-systems:
macOS:
Expand Down Expand Up @@ -1436,7 +1443,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.ios.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.7.1/PubNub.ios.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.8.0/PubNub.ios.xcframework.tar.gz
supported-platforms:
supported-operating-systems:
iOS:
Expand All @@ -1455,7 +1462,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.macos.framework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.7.1/PubNub.macos.framework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.8.0/PubNub.macos.framework.tar.gz
supported-platforms:
supported-operating-systems:
macOS:
Expand All @@ -1471,7 +1478,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.tvos.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.7.1/PubNub.tvos.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.8.0/PubNub.tvos.xcframework.tar.gz
supported-platforms:
supported-operating-systems:
tvOS:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v5.8.0
February 27 2025

#### Added
- Add support for `type` and `status` fields for all App Context entities: `channel`, `uuid`, `membership`, and `member`.
- Add `If-Match` header support to set `Channel` and `UUID` metadata app context objects.

## v5.7.1
February 03 2025

Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-iOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-tvOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-watchOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.7.1</string>
<string>5.8.0</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion PubNub.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Pod::Spec.new do |spec|
spec.name = 'PubNub'
spec.version = '5.7.1'
spec.version = '5.8.0'
spec.summary = 'The PubNub Real-Time Network. Build real-time apps quickly and scale them globally.'
spec.homepage = 'https://github.com/pubnub/objective-c'

Expand Down
6 changes: 6 additions & 0 deletions PubNub/Data/Models/PNBaseAppContextObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ NS_ASSUME_NONNULL_BEGIN
/// > Note: Value will be `nil` for objects received through subscribe real-time updates.
@property(strong, nullable, nonatomic, readonly) NSDate *updated;

///`App Context` object status.
@property(copy, nullable, nonatomic, readonly) NSString *status;

/// `App Context` object version identifier.
///
/// > Note: Value will be `nil` for objects received through subscribe real-time updates.
@property(copy, nullable, nonatomic, readonly) NSString *eTag;

/// `App Context` object type information.
@property(copy, nullable, nonatomic, readonly) NSString *type;

#pragma mark -


Expand Down
4 changes: 3 additions & 1 deletion PubNub/Data/Models/PNBaseAppContextObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ @implementation PNBaseAppContextObject

+ (NSDictionary<NSString *,NSString *> *)codingKeys {
return @{
@"status": @"status",
@"type": @"type",
@"custom": @"custom",
@"updated": @"updated",
@"eTag": @"eTag",
};
}

+ (NSArray<NSString *> *)optionalKeys {
return @[@"custom", @"updated", @"eTag"];
return @[@"custom", @"status", @"type", @"updated", @"eTag"];
}


Expand Down
2 changes: 1 addition & 1 deletion PubNub/Misc/PNConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#pragma mark General information constants

// Stores client library version number
static NSString * const kPNLibraryVersion = @"5.7.1";
static NSString * const kPNLibraryVersion = @"5.8.0";

// Stores information about SDK codebase
static NSString * const kPNCommit = @"fd5c7ed678527fce07eaf7eb162935caf1bfd303";
Expand Down
70 changes: 55 additions & 15 deletions PubNub/Misc/PNStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,17 +535,29 @@ typedef NS_ENUM(NSUInteger, PNAPNSEnvironment) {
/// Options with possible additional `channel` / `membership` fields which can be included to response.
typedef NS_OPTIONS(NSUInteger, PNMembershipFields) {
/// Include how many memberships `UUID` has.
PNMembershipsTotalCountField = 1 << 4,
PNMembershipsTotalCountField = 1 << 0,

/// Include field with additional information from `metadata` which has been associated with `UUID` during
/// `membership set` requests.
PNMembershipCustomField = 1 << 5,

PNMembershipCustomField = 1 << 1,

/// Include field with `metadata` status which has been associated with `UUID` during `membership set` requests.
PNMembershipStatusField = 1 << 2,

/// Include field with `metadata` type which has been associated with `UUID` during `membership set` requests.
PNMembershipTypeField = 1 << 3,

/// Include `channel`'s `metadata` into response (not only name).
PNMembershipChannelField = 1 << 6,
PNMembershipChannelField = 1 << 4,

/// Include `channel`'s additional information which has been used during `channel` `metadata set` requests.
PNMembershipChannelCustomField = 1 << 7
PNMembershipChannelCustomField = 1 << 5,

/// Include `channel`'s `status` which has been used during `channel` `metadata set` requests.
PNMembershipChannelStatusField = 1 << 6,

/// Include `channel`'s `type` which has been used during `channel` `metadata set` requests.
PNMembershipChannelTypeField = 1 << 7
};

/// Options with possible additional `UUID` / `member` fields which can be included to response.
Expand All @@ -557,31 +569,59 @@ typedef NS_OPTIONS(NSUInteger, PNChannelMemberFields) {
/// member set` requests.
PNChannelMemberCustomField = 1 << 9,

/// Include field with `metadata` status which has been associated with `UUID` during `channel member set` requests.
PNChannelMemberStatusField = 1 << 10,

/// Include field with `metadata` type which has been associated with `UUID` during `channel member set` requests.
PNChannelMemberTypeField = 1 << 11,

/// Include `UUID`'s `metadata` into response (not only identifier).
PNChannelMemberUUIDField = 1 << 10,
PNChannelMemberUUIDField = 1 << 12,

/// Include `UUID`'s additional information which has been used during `UUID metadata set` requests.
PNChannelMemberUUIDCustomField = 1 << 11
PNChannelMemberUUIDCustomField = 1 << 13,

/// Include `UUID`'s `status` which has been used during `UUID metadata set` requests.
PNChannelMemberUUIDStatusField = 1 << 14,

/// Include `UUID`'s `type` which has been used during `UUID metadata set` requests.
PNChannelMemberUUIDTypeField = 1 << 15
};

/// Options with possible additional `channel` fields which can be included to response.
typedef NS_OPTIONS(NSUInteger, PNChannelFields) {
/// Include how many `channels` has been associated with `metadata`.
PNChannelTotalCountField = 1 << 0,

///
/// > Note: Available only when fetching list of channels metadata.
PNChannelTotalCountField = 1 << 16,

/// Include field with additional information from `metadata` which has been used during `channel metadata set`
/// requests.
PNChannelCustomField = 1 << 1
PNChannelCustomField = 1 << 17,

/// Include field with `metadata` status which has been used during `channel metadata set` requests.
PNChannelStatusField = 1 << 18,

/// Include field with `metadata` type which has been used during `channel metadata set` requests.
PNChannelTypeField = 1 << 19
};

/// Options with possible additional `UUID` fields which can be included to response.
typedef NS_OPTIONS(NSUInteger, PNUUIDFields) {
/// Include how many `UUID` has been associated with `metadata`.
PNUUIDTotalCountField = 1 << 2,

///
/// > Note: Available only when fetching list of UUIDs metadatas.
PNUUIDTotalCountField = 1 << 20,

/// Include field with additional information from `metadata` which has been used during `UUID metadata set`
/// requests.
PNUUIDCustomField = 1 << 3
PNUUIDCustomField = 1 << 21,

/// Include field with `metadata` status which has been used during `UUID metadata set` requests.
PNUUIDStatusField = 1 << 22,

/// Include field with `metadata` type which has been used during `UUID metadata set` requests.
PNUUIDTypeField = 1 << 23
};

/// Options describe possible heartbeat states on which delegate can be notified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ NS_ASSUME_NONNULL_BEGIN

#pragma mark - Properties

/// Optional entity tag from a previously received ``PNChannelMetadata``.
///
/// The request will fail if this parameter is specified and the ETag value on the server doesn't match.
@property(strong, nullable, nonatomic) NSString *ifMatchesEtag;

/// Additional / complex attributes which should be stored in `metadata` associated with specified `channel`.
@property(nonatomic, nullable, strong) NSDictionary *custom;

Expand All @@ -23,6 +28,12 @@ NS_ASSUME_NONNULL_BEGIN
/// Description which should be stored in `metadata` associated with specified `channel`.
@property(copy, nullable, nonatomic) NSString *information;

/// UUID's `metadata` object `status`.
@property(strong, nullable, nonatomic) NSString *status;

/// UUID's `metadata` object `type`.
@property(strong, nullable, nonatomic) NSString *type;

/// Name which should be stored in `metadata` associated with specified `channel`.
@property(copy, nonatomic) NSString *name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ - (NSDictionary *)headers {
NSMutableDictionary *headers =[([super headers] ?: @{}) mutableCopy];
headers[@"Content-Type"] = @"application/json";

if (self.ifMatchesEtag) headers[@"If-Match"] = self.ifMatchesEtag;

return headers;
}

Expand Down Expand Up @@ -91,8 +93,10 @@ - (PNError *)validate {

if (self.name) info[@"name"] = self.name;
if (self.information.length) info[@"description"] = self.information;
if (self.status.length) info[@"status"] = self.status;
if (self.custom.count) info[@"custom"] = self.custom;

if (self.type.length) info[@"type"] = self.type;

if ([NSJSONSerialization isValidJSONObject:info]) {
self.body = [NSJSONSerialization dataWithJSONObject:info options:(NSJSONWritingOptions)0 error:&error];
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ - (TransportMethod)httpMethod {
return TransportPATCHMethod;
}

- (NSDictionary *)headers {
NSMutableDictionary *headers =[([super headers] ?: @{}) mutableCopy];
headers[@"Content-Type"] = @"application/json";

return headers;
}


#pragma mark - Initialization and Configuration

Expand Down Expand Up @@ -150,6 +157,9 @@ - (NSArray *)serializedObjectType:(NSString *)type fromArray:(NSArray<NSDictiona
}
}

if (object[@"status"]) objectData[@"status"] = object[@"status"];
if (object[@"type"]) objectData[@"type"] = object[@"type"];

[serializedObjects addObject:objectData];
}

Expand Down
Loading

0 comments on commit 053b156

Please sign in to comment.