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

JSON decoder / encoder #459

Merged
merged 20 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
113 changes: 113 additions & 0 deletions Example/PubNub Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@
6003F5A7195388D20070C39A /* PNViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5A6195388D20070C39A /* PNViewController.m */; };
6003F5A9195388D20070C39A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5A8195388D20070C39A /* Images.xcassets */; };
793D26AF1B44049400509447 /* VERSION in Resources */ = {isa = PBXBuildFile; fileRef = 793D26AE1B44049400509447 /* VERSION */; };
7DFA59668F8962F1DB5BB4D9 /* Pods_PubNub_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9461CA89B697BEF100833EE7 /* Pods_PubNub_Example.framework */; };
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
A530F8C524085644001B2B08 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = A530F8C424085644001B2B08 /* CHANGELOG.md */; };
A530F8C624085644001B2B08 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = A530F8C424085644001B2B08 /* CHANGELOG.md */; };
AB71875182EA91F6374CDF5C /* Pods_PubNub_Mac_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8EE0E49599119A49A95A63B /* Pods_PubNub_Mac_Example.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
0B89A73F207765234DEF5D84 /* Pods-PubNub Mac Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PubNub Mac Example.debug.xcconfig"; path = "Target Support Files/Pods-PubNub Mac Example/Pods-PubNub Mac Example.debug.xcconfig"; sourceTree = "<group>"; };
160E67ED754721C408CB2C10 /* Pods-PubNub Mac Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PubNub Mac Example.release.xcconfig"; path = "Target Support Files/Pods-PubNub Mac Example/Pods-PubNub Mac Example.release.xcconfig"; sourceTree = "<group>"; };
3D2C65090A1239D5298096DD /* Pods-PubNub_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PubNub_Example.release.xcconfig"; path = "Target Support Files/Pods-PubNub_Example/Pods-PubNub_Example.release.xcconfig"; sourceTree = "<group>"; };
511725D41BE92F7B008F069E /* PubNub Mac Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PubNub Mac Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
511725D61BE92F7B008F069E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
511725D71BE92F7B008F069E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
Expand All @@ -53,16 +58,20 @@
793D26AE1B44049400509447 /* VERSION */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = VERSION; path = ../VERSION; sourceTree = "<group>"; };
7A9945019D33BCC2C3B3B7C1 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
9461CA89B697BEF100833EE7 /* Pods_PubNub_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PubNub_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
97FB4DB81B36266800CA7C91 /* Rakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Rakefile; path = ../Rakefile; sourceTree = "<group>"; };
A530F8C424085644001B2B08 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = CHANGELOG.md; path = ../CHANGELOG.md; sourceTree = "<group>"; };
C4C1ED79724D56B45766CFFA /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
CDB3FA99F58B32801E637621 /* Pods-PubNub_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PubNub_Example.debug.xcconfig"; path = "Target Support Files/Pods-PubNub_Example/Pods-PubNub_Example.debug.xcconfig"; sourceTree = "<group>"; };
F8EE0E49599119A49A95A63B /* Pods_PubNub_Mac_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PubNub_Mac_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
511725D11BE92F7B008F069E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
AB71875182EA91F6374CDF5C /* Pods_PubNub_Mac_Example.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -73,6 +82,7 @@
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */,
6003F592195388D20070C39A /* UIKit.framework in Frameworks */,
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */,
7DFA59668F8962F1DB5BB4D9 /* Pods_PubNub_Example.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -110,6 +120,7 @@
511725D51BE92F7B008F069E /* PubNub Mac Example */,
6003F58C195388D20070C39A /* Frameworks */,
6003F58B195388D20070C39A /* Products */,
9FF2D32EAFD97DF648CDF4B1 /* Pods */,
);
sourceTree = "<group>";
};
Expand All @@ -128,6 +139,8 @@
6003F58D195388D20070C39A /* Foundation.framework */,
6003F58F195388D20070C39A /* CoreGraphics.framework */,
6003F591195388D20070C39A /* UIKit.framework */,
F8EE0E49599119A49A95A63B /* Pods_PubNub_Mac_Example.framework */,
9461CA89B697BEF100833EE7 /* Pods_PubNub_Example.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -171,17 +184,31 @@
name = "Podspec Metadata";
sourceTree = "<group>";
};
9FF2D32EAFD97DF648CDF4B1 /* Pods */ = {
isa = PBXGroup;
children = (
0B89A73F207765234DEF5D84 /* Pods-PubNub Mac Example.debug.xcconfig */,
160E67ED754721C408CB2C10 /* Pods-PubNub Mac Example.release.xcconfig */,
CDB3FA99F58B32801E637621 /* Pods-PubNub_Example.debug.xcconfig */,
3D2C65090A1239D5298096DD /* Pods-PubNub_Example.release.xcconfig */,
);
name = Pods;
path = ../Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
511725D31BE92F7B008F069E /* PubNub Mac Example */ = {
isa = PBXNativeTarget;
buildConfigurationList = 511725F41BE92F7B008F069E /* Build configuration list for PBXNativeTarget "PubNub Mac Example" */;
buildPhases = (
8435A4BE5155584AC07DB6FB /* [CP] Check Pods Manifest.lock */,
511725D01BE92F7B008F069E /* Sources */,
511725D11BE92F7B008F069E /* Frameworks */,
511725D21BE92F7B008F069E /* Resources */,
79258BFB218645C4009C5FBE /* Cleanup CocoaPods scripts */,
78645B070C8D8B4E81E9E2C3 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand All @@ -196,10 +223,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "PubNub_Example" */;
buildPhases = (
DC271207DBC0996E32D0AC6B /* [CP] Check Pods Manifest.lock */,
6003F586195388D20070C39A /* Sources */,
6003F587195388D20070C39A /* Frameworks */,
6003F588195388D20070C39A /* Resources */,
79258BF9218645A0009C5FBE /* Cleanup CocoaPods scripts */,
0A15041918330536131A9B8F /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -273,6 +302,42 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
0A15041918330536131A9B8F /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-PubNub_Example/Pods-PubNub_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/PubNub-iOS/PubNub.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PubNub.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PubNub_Example/Pods-PubNub_Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
78645B070C8D8B4E81E9E2C3 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-PubNub Mac Example/Pods-PubNub Mac Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/PubNub-macOS/PubNub.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PubNub.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PubNub Mac Example/Pods-PubNub Mac Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
79258BF9218645A0009C5FBE /* Cleanup CocoaPods scripts */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -301,6 +366,50 @@
shellPath = /bin/sh;
shellScript = "find \"${TARGET_TEMP_DIR}\" -name 'Script-*.sh' -exec rm -rf {} \\;\n";
};
8435A4BE5155584AC07DB6FB /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-PubNub Mac Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
DC271207DBC0996E32D0AC6B /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-PubNub_Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -348,6 +457,7 @@
/* Begin XCBuildConfiguration section */
511725F01BE92F7B008F069E /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 0B89A73F207765234DEF5D84 /* Pods-PubNub Mac Example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
Expand All @@ -370,6 +480,7 @@
};
511725F11BE92F7B008F069E /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 160E67ED754721C408CB2C10 /* Pods-PubNub Mac Example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
Expand Down Expand Up @@ -527,6 +638,7 @@
};
6003F5C0195388D20070C39A /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = CDB3FA99F58B32801E637621 /* Pods-PubNub_Example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
Expand Down Expand Up @@ -560,6 +672,7 @@
};
6003F5C1195388D20070C39A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3D2C65090A1239D5298096DD /* Pods-PubNub_Example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
Expand Down
68 changes: 64 additions & 4 deletions Example/PubNub/PNAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.channel1 = @"bot";
self.channel2 = @"myCh";
self.channelGroup1 = @"myChannelGroup";
self.pubKey = @"demo";
self.subKey = @"demo";
self.pubKey = @"pub-c-92e62c76-408a-4ac4-aefc-a1d20a83b2a6";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Fixed.

self.subKey = @"sub-c-d0b8e542-12a0-41c4-999f-a2d569dc4255";
self.authKey = @"myAuthKey";


Expand Down Expand Up @@ -92,15 +92,75 @@ - (void)pubNubInit {
self.client.logger.maximumNumberOfLogFiles = 10;
[self.client.logger setLogLevel:PNVerboseLogLevel];


// Bind didReceiveMessage, didReceiveStatus, and didReceivePresenceEvent 'listeners' to this delegate
// just be sure the target has implemented the PNObjectEventListener extension
[self.client addListener:self];
[self pubNubSetState];
// [self.client addListener:self];
// [self pubNubSetState];
}

- (void)tireKicker {
[self pubNubInit];
// public.channel.5


PNHereNowRequest *request = [PNHereNowRequest requestGlobal];
request.verbosityLevel = PNHereNowState;
[self.client hereNowWithRequest:request completion:^(PNPresenceHereNowResult *result, PNErrorStatus *status) {
NSLog(@"~~~~~> RESULT: %@", result);
NSLog(@"~~~~~> RESULT DATA: %@", result.data.channels[@"public.channel.5"].uuids.firstObject.uuid);
NSLog(@"~~~~~> STATUS: %@", status);
if (!status.isError) {
// Handle downloaded presence information using:
// `result.data.channels` - dictionary with active channels and presence information on each. Each channel
// will have next fields: `uuids` - list of subscribers; `occupancy` - number of
// active subscribers.
// Each uuids entry has next fields: `uuid` - identifier and `state` if it has been
// provided.
// `result.data.totalChannels` - total number of active channels.
// `result.data.totalOccupancy` - total number of active subscribers.
} else {
// Handle presence audit error. Check `category` property to find out possible issue because of which
// request did fail.
}
}];


//
//
//
//
//
//
// PNPublishRequest *request = [PNPublishRequest requestWithChannel:@""];
// request.metadata = @{ @"to": @"John Doe" };
// request.message = @{ @"Hello": @"world" };
//
// [self.client publishWithRequest:request completion:^(PNPublishStatus *status) {
// NSLog(@"~~~~~> STATUS: %@", status);
// NSLog(@"~~~~~> ERROR DATA: %@", status.stringifiedCategory);
// NSLog(@"~~~~~> TIME: %@", status.data.timetoken);
// if (!status.isError) {
// // Message successfully published to specified channel. Publish time stored in: `result.data.timetoken`.
// } else {
// // Handle message publish error. Check `category` property to find out possible issue because of which
// // request did fail.
// }
// }];



// NSLog(@"~~~~~=======> 1");
// PNListChannelGroupChannelsRequest *request = [PNListChannelGroupChannelsRequest requestWithChannelGroup:@"holla"];
// NSLog(@"~~~~~=======> 2: %@", request);
//
// [self.client listChannelsForChannelGroupWithRequest:request
// completion:^(PNResponse<PNChannelGroupChannels *> *response, PNErrorStatus *status){
// NSLog(@"~~~~~=======> 3");
// }];
// NSLog(@"~~~~~=======> 4");

return;
#pragma mark - Time

[self pubNubTime];
Expand Down
7 changes: 7 additions & 0 deletions Example/PubNub/PubNub Example-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>ps.pndsn.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>pubsub.pubnub.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
Expand Down
Loading
Loading