Skip to content

Commit

Permalink
Add changes before PubNub Swift Chat SDK 0.9.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
jguz-pubnub committed Dec 13, 2024
1 parent eb4457a commit 77accc6
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 96 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/pubnub/kmp-chat", exact: "0.9.0-dev"),
.package(url: "https://github.com/pubnub/swift", exact: "8.0.1")
.package(url: "https://github.com/pubnub/kmp-chat", exact: "0.9.2-dev"),
.package(url: "https://github.com/pubnub/swift", exact: "8.2.2")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
34 changes: 19 additions & 15 deletions PubNubSwiftChatSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
3D2CA2482C621876008D2284 /* MessageActionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D2CA2472C621876008D2284 /* MessageActionType.swift */; };
3D334BD02C8EE9E500F8793C /* PubNub.PushService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D334BCF2C8EE9E500F8793C /* PubNub.PushService.swift */; };
3D334BD22C8EEAA800F8793C /* PubNub.PushEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D334BD12C8EEAA800F8793C /* PubNub.PushEnvironment.swift */; };
3D79EB842D0C39C100F7AB56 /* PubNubChat in Frameworks */ = {isa = PBXBuildFile; productRef = 3D79EB832D0C39C100F7AB56 /* PubNubChat */; };
3D79EB862D0C40ED00F7AB56 /* PubNubChat.PubNubError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D79EB852D0C40ED00F7AB56 /* PubNubChat.PubNubError.swift */; };
3D7BBF6F2C8893D400FBA623 /* ChatAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D7BBF6E2C8893D400FBA623 /* ChatAdapter.swift */; };
3D83621A2CC7B35200A21B9A /* MessageDraftChangeListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8362192CC7B35200A21B9A /* MessageDraftChangeListener.swift */; };
3D842D242C9DC0AA005C0B55 /* ErrorConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D842D232C9DC0AA005C0B55 /* ErrorConstants.swift */; };
Expand Down Expand Up @@ -80,7 +82,6 @@
3DB73A7D2C57EA94007FE249 /* Timetoken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB73A7C2C57EA94007FE249 /* Timetoken.swift */; };
3DB73A7F2C58CCAE007FE249 /* GetCurrentUserMentionsResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB73A7E2C58CCAE007FE249 /* GetCurrentUserMentionsResult.swift */; };
3DCF7DFC2CD0FFCC00889326 /* PubNubSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 3DCF7DFB2CD0FFCC00889326 /* PubNubSDK */; };
3DCF7DFF2CD1226100889326 /* PubNubChat in Frameworks */ = {isa = PBXBuildFile; productRef = 3DCF7DFE2CD1226100889326 /* PubNubChat */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -121,6 +122,7 @@
3D2CA2472C621876008D2284 /* MessageActionType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageActionType.swift; sourceTree = "<group>"; };
3D334BCF2C8EE9E500F8793C /* PubNub.PushService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNub.PushService.swift; sourceTree = "<group>"; };
3D334BD12C8EEAA800F8793C /* PubNub.PushEnvironment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNub.PushEnvironment.swift; sourceTree = "<group>"; };
3D79EB852D0C40ED00F7AB56 /* PubNubChat.PubNubError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNubChat.PubNubError.swift; sourceTree = "<group>"; };
3D7BBF6E2C8893D400FBA623 /* ChatAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatAdapter.swift; sourceTree = "<group>"; };
3D8362192CC7B35200A21B9A /* MessageDraftChangeListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageDraftChangeListener.swift; sourceTree = "<group>"; };
3D842D232C9DC0AA005C0B55 /* ErrorConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorConstants.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -190,7 +192,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3DCF7DFF2CD1226100889326 /* PubNubChat in Frameworks */,
3D79EB842D0C39C100F7AB56 /* PubNubChat in Frameworks */,
3DCF7DFC2CD0FFCC00889326 /* PubNubSDK in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -317,6 +319,7 @@
3D2CA23D2C5BBCDB008D2284 /* PubNubChat.PNPushType.swift */,
3D2CA23F2C5BBDB6008D2284 /* PubNubChat.PNPushEnvironment.swift */,
3DB73A742C57D073007FE249 /* PubNubChat.Event.swift */,
3D79EB852D0C40ED00F7AB56 /* PubNubChat.PubNubError.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -398,7 +401,7 @@
name = PubNubSwiftChatSDK;
packageProductDependencies = (
3DCF7DFB2CD0FFCC00889326 /* PubNubSDK */,
3DCF7DFE2CD1226100889326 /* PubNubChat */,
3D79EB832D0C39C100F7AB56 /* PubNubChat */,
);
productName = PubNubChatSDK;
productReference = 3DB73A072C4FE13C007FE249 /* PubNubSwiftChatSDK.framework */;
Expand Down Expand Up @@ -452,7 +455,7 @@
mainGroup = 3DB739FD2C4FE13B007FE249;
packageReferences = (
3DCF7DFA2CD0FFCC00889326 /* XCRemoteSwiftPackageReference "swift" */,
3DCF7DFD2CD1226100889326 /* XCRemoteSwiftPackageReference "kmp-chat" */,
3D79EB822D0C39C100F7AB56 /* XCRemoteSwiftPackageReference "kmp-chat" */,
);
productRefGroup = 3DB73A082C4FE13C007FE249 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -522,6 +525,7 @@
3DB73A652C57A782007FE249 /* CreateDirectConversationResult.swift in Sources */,
3DB73A5D2C53CC0A007FE249 /* ThreadChannelImpl.swift in Sources */,
3D334BD22C8EEAA800F8793C /* PubNub.PushEnvironment.swift in Sources */,
3D79EB862D0C40ED00F7AB56 /* PubNubChat.PubNubError.swift in Sources */,
3DB73A4F2C52881A007FE249 /* PubNubChat.ChannelType.swift in Sources */,
3DB73A6B2C57B9D8007FE249 /* GetUnreadMessagesCount.swift in Sources */,
3DB49E212C761BD1006356ED /* AutoCloseable.swift in Sources */,
Expand Down Expand Up @@ -877,35 +881,35 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
3DCF7DFA2CD0FFCC00889326 /* XCRemoteSwiftPackageReference "swift" */ = {
3D79EB822D0C39C100F7AB56 /* XCRemoteSwiftPackageReference "kmp-chat" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/pubnub/swift";
repositoryURL = "https://github.com/pubnub/kmp-chat";
requirement = {
kind = exactVersion;
version = 8.0.1;
version = "0.9.2-dev";
};
};
3DCF7DFD2CD1226100889326 /* XCRemoteSwiftPackageReference "kmp-chat" */ = {
3DCF7DFA2CD0FFCC00889326 /* XCRemoteSwiftPackageReference "swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/pubnub/kmp-chat";
repositoryURL = "https://github.com/pubnub/swift";
requirement = {
kind = exactVersion;
version = "0.9.0-dev";
version = 8.2.2;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
3D79EB832D0C39C100F7AB56 /* PubNubChat */ = {
isa = XCSwiftPackageProductDependency;
package = 3D79EB822D0C39C100F7AB56 /* XCRemoteSwiftPackageReference "kmp-chat" */;
productName = PubNubChat;
};
3DCF7DFB2CD0FFCC00889326 /* PubNubSDK */ = {
isa = XCSwiftPackageProductDependency;
package = 3DCF7DFA2CD0FFCC00889326 /* XCRemoteSwiftPackageReference "swift" */;
productName = PubNubSDK;
};
3DCF7DFE2CD1226100889326 /* PubNubChat */ = {
isa = XCSwiftPackageProductDependency;
package = 3DCF7DFD2CD1226100889326 /* XCRemoteSwiftPackageReference "kmp-chat" */;
productName = PubNubChat;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 3DB739FE2C4FE13C007FE249 /* Project object */;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
1. Create or open your project inside Xcode.
2. Navigate to **File -> Add Package Dependencies**.
3. Search for `https://github.com/pubnub/swift-chat-sdk`
4. From the **Dependency Rule** drop-down list, select **Exact**. In the version input field, type `0.9.1-dev`
4. From the **Dependency Rule** drop-down list, select **Exact**. In the version input field, type `0.9.2-dev`
5. Click the **Add Package** button.

For more information see Apple's guide on [Adding Package Dependencies to Your App](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app)
Expand Down
28 changes: 0 additions & 28 deletions Sources/Chat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -435,34 +435,6 @@ public protocol Chat: AnyObject {
completion: ((Swift.Result<(memberships: [ChatMembershipType], page: PubNubHashedPage?), Error>) -> Void)?
)

/// Retrieves all channels that match the provided 3-letter string from your app's keyset.
///
/// - Parameters:
/// - text: At least a 3-letter string typed in after `#` with the channel name you want to reference
/// - limit: Maximum number of returned channel names that match the typed 3-letter suggestion
/// - completion: The async `Result` of the method call
/// - **Success**: An array of ``Channel`` objects
/// - **Failure**: An `Error` describing the failure
func getChannelSuggestions(
text: String,
limit: Int,
completion: ((Swift.Result<[ChatChannelType], Error>) -> Void)?
)

/// Returns all suggested users that match the provided 3-letter string.
///
/// - Parameters:
/// - text: At least a 3-letter string typed in after `@` with the user name you want to mention
/// - limit: Maximum number of returned usernames that match the typed 3-letter suggestion
/// - completion: The async `Result` of the method call
/// - **Success**: An array of ``Channel`` objects
/// - **Failure**: An `Error` describing the failure
func getUserSuggestions(
text: String,
limit: Int,
completion: ((Swift.Result<[ChatUserType], Error>) -> Void)?
)

/// Retrieves all channels where your registered device receives push notifications.
///
/// - Parameters:
Expand Down
40 changes: 0 additions & 40 deletions Sources/ChatImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -658,46 +658,6 @@ extension ChatImpl: Chat {
}
}

public func getChannelSuggestions(
text: String,
limit: Int = 10,
completion: ((Swift.Result<[ChannelImpl], Error>) -> Void)? = nil
) {
chat.getChannelSuggestions(
text: text,
limit: Int32(limit)
).async(caller: self) { (result: FutureResult<ChatImpl, [PubNubChat.Channel_]>) in
switch result.result {
case let .success(channels):
completion?(.success(channels.compactMap {
ChannelImpl(channel: $0)
}))
case let .failure(error):
completion?(.failure(error))
}
}
}

public func getUserSuggestions(
text: String,
limit: Int = 10,
completion: ((Swift.Result<[UserImpl], Error>) -> Void)? = nil
) {
chat.getUserSuggestions(
text: text,
limit: Int32(limit)
).async(caller: self) { (result: FutureResult<ChatImpl, [PubNubChat.User]>) in
switch result.result {
case let .success(users):
completion?(.success(users.compactMap {
UserImpl(user: $0)
}))
case let .failure(error):
completion?(.failure(error))
}
}
}

public func getPushChannels(completion: ((Swift.Result<[String], Error>) -> Void)? = nil) {
chat.getPushChannels().async(caller: self) { (result: FutureResult<ChatImpl, [String]>) in
switch result.result {
Expand Down
1 change: 1 addition & 0 deletions Sources/Entities/BaseMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extension BaseMessage: Message {
public var files: [File] { message.files.transform() }
public var reactions: [String: [Action]] { message.reactions.transform() }
public var textLinks: [TextLink]? { message.textLinks?.transform() }
public var error: Error? { message.error }

static func streamUpdatesOn(
messages: [BaseMessage],
Expand Down
2 changes: 1 addition & 1 deletion Sources/Entities/MembershipImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extension MembershipImpl: Membership {
completion: ((Swift.Result<MembershipImpl, Error>) -> Void)? = nil
) {
membership.update(
custom: CustomObject(value: custom)
custom: custom
).async(caller: self) { (result: FutureResult<MembershipImpl, PubNubChat.Membership>) in
switch result.result {
case let .success(membership):
Expand Down
2 changes: 2 additions & 0 deletions Sources/Entities/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public protocol Message {
var files: [File] { get }
/// List of reactions attached to the given ``Message``
var reactions: [String: [Action]] { get }
/// Error associated with the message, if any
var error: Error? { get }

/// Receive updates when specific messages and related message reactions are added, edited, or removed.
///
Expand Down
4 changes: 3 additions & 1 deletion Sources/Entities/MessageImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public final class MessageImpl {
channelId: channelId,
userId: userId,
actions: actions?.transform(),
metaInternal: JsonElementImpl(value: meta?.compactMapValues { $0.rawValue })
metaInternal: JsonElementImpl(value: meta?.compactMapValues { $0.rawValue }),
error: nil
)
self.init(
message: underlyingMessage
Expand Down Expand Up @@ -77,6 +78,7 @@ extension MessageImpl: Message {
public var files: [File] { target.files }
public var reactions: [String: [Action]] { target.reactions }
public var textLinks: [TextLink]? { target.textLinks }
public var error: Error? { target.error }

public static func streamUpdatesOn(
messages: [MessageImpl],
Expand Down
9 changes: 4 additions & 5 deletions Sources/Entities/ThreadMessageImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ public final class ThreadMessageImpl {
channelId: String,
userId: String,
actions: [String: [String: [Action]]]? = nil,
meta: [String: JSONCodable]? = nil,
mentionedUsers: MessageMentionedUsers? = nil,
referencedChannels: MessageReferencedChannels? = nil,
quotedMessage: QuotedMessage? = nil
meta: [String: JSONCodable]? = nil
) {
let underlyingThreadMessage = PubNubChat.ThreadMessageImpl(
chat: chat.chat,
Expand All @@ -44,7 +41,8 @@ public final class ThreadMessageImpl {
channelId: channelId,
userId: userId,
actions: actions?.transform(),
metaInternal: JsonElementImpl(value: meta?.compactMapValues { $0.rawValue })
metaInternal: JsonElementImpl(value: meta?.compactMapValues { $0.rawValue }),
error: nil
)
self.init(
message: underlyingThreadMessage
Expand Down Expand Up @@ -89,6 +87,7 @@ extension ThreadMessageImpl: ThreadMessage {
public var reactions: [String: [Action]] { target.reactions }
public var textLinks: [TextLink]? { target.textLinks }
public var parentChannelId: String { target.message.parentChannelId }
public var error: Error? { target.message.error }

public static func streamUpdatesOn(
messages: [ThreadMessageImpl],
Expand Down
4 changes: 2 additions & 2 deletions Sources/Extensions/Dictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ extension [String: [String: [Action]]] {
}

extension [String: JSONCodableScalar] {
func asCustomObject() -> PubNubChat.CustomObject {
PubNubChat.CustomObject(value: self)
func asCustomObject() -> [String: Any] {
Factories_nonJvmKt.createCustomObject(map: self)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Extensions/PubNub.MembershipSortField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension PubNub.MembershipSortField {
case .type, .status:
return nil
}
case .status:
case .type, .status:
return nil
case .updated:
return ascending ? PNSortKeyPNAsc(key: PNMembershipKey.updated) : PNSortKeyPNDesc(key: .updated)
Expand Down
16 changes: 16 additions & 0 deletions Sources/Extensions/PubNubChat.PubNubError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// PubNubChat.PubNubError.swift
//
// Copyright (c) PubNub Inc.
// All rights reserved.
//
// This source code is licensed under the license found in the
// LICENSE file in the root directory of this source tree.
//

import Foundation
import PubNubChat

extension PubNubChat.PubNubError: Error {

}

0 comments on commit 77accc6

Please sign in to comment.