Skip to content

Commit e812c9a

Browse files
authored
Customer interface cleanup and documentation enhancements (#14)
fix(chat): remove `createUser(user:completion:)` method from the public interface fix(chat): add missing `reactionsActionName` computed property refactor(documentation): documentation enhancements
1 parent 211f1a5 commit e812c9a

File tree

11 files changed

+66
-60
lines changed

11 files changed

+66
-60
lines changed

.pubnub.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
---
22
name: swift-chat-sdk
33
scm: github.com/pubnub/swift-chat-sdk
4-
version: "0.10.0"
4+
version: "0.10.1"
55
schema: 1
66
changelog:
7+
- date: 2025-01-09
8+
version: 0.10.1
9+
changes:
10+
- type: bug
11+
text: "Remove `createUser(user:completion:)` method from the public interface."
12+
- type: bug
13+
text: "Add missing `reactionsActionName` computed property."
14+
- type: improvement
15+
text: "Documentation enhancements."
716
- date: 2025-01-08
817
version: 0.10.0
918
changes:
@@ -82,7 +91,7 @@ sdks:
8291
- distribution-type: source
8392
distribution-repository: GitHub release
8493
package-name: PubNubSwiftChatSDK
85-
location: https://github.com/pubnub/swift-chat-sdk/archive/refs/tags/0.10.0-dev.zip
94+
location: https://github.com/pubnub/swift-chat-sdk/archive/refs/tags/0.10.1-dev.zip
8695
supported-platforms:
8796
supported-operating-systems:
8897
iOS:

PubNubSwiftChatSDK.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@
733733
"@loader_path/Frameworks",
734734
);
735735
MACOSX_DEPLOYMENT_TARGET = 11.0;
736-
MARKETING_VERSION = 0.10.0;
736+
MARKETING_VERSION = 0.10.1;
737737
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
738738
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
739739
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS";
@@ -782,7 +782,7 @@
782782
"@loader_path/Frameworks",
783783
);
784784
MACOSX_DEPLOYMENT_TARGET = 11.0;
785-
MARKETING_VERSION = 0.10.0;
785+
MARKETING_VERSION = 0.10.1;
786786
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
787787
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
788788
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS";

PubNubSwiftChatSDK/PubNubSwiftChatSDK.docc/Chat.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Topics
44

5+
### Initializing a Chat instance
6+
7+
- ``initialize(completion:)``
8+
59
### Working with Conversations
610

711
- ``CreateDirectConversationResult``
@@ -25,7 +29,7 @@
2529
### Working with Users
2630

2731
- ``getUser(userId:completion:)``
28-
- ``createUser(user:completion:)``
32+
- ``createUser(id:name:externalId:profileUrl:email:custom:status:type:completion:)``
2933
- ``getUsers(filter:sort:limit:page:completion:)``
3034
- ``updateUser(id:name:externalId:profileUrl:email:custom:status:type:completion:)``
3135
- ``deleteUser(id:soft:completion:)``
@@ -48,11 +52,6 @@
4852
- ``getUnreadMessagesCount(limit:page:filter:sort:completion:)``
4953
- ``markAllMessagesAsRead(limit:page:filter:sort:completion:)``
5054

51-
### Working with Channels and Users Suggestions
52-
53-
- ``getUserSuggestions(text:limit:completion:)``
54-
- ``getChannelSuggestions(text:limit:completion:)``
55-
5655
### Retrieving Current User Mentions
5756

5857
- ``UserMentionData``

PubNubSwiftChatSDK/PubNubSwiftChatSDK.docc/ChatImpl.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Topics
44

5+
### Initializing a Chat instance
6+
7+
- ``init(chatConfiguration:pubNubConfiguration:)``
8+
- ``initialize(completion:)``
9+
510
### Working with Conversations
611

712
- ``CreateDirectConversationResult``
@@ -25,7 +30,7 @@
2530
### Working with Users
2631

2732
- ``getUser(userId:completion:)``
28-
- ``createUser(user:completion:)``
33+
- ``createUser(id:name:externalId:profileUrl:email:custom:status:type:completion:)``
2934
- ``getUsers(filter:sort:limit:page:completion:)``
3035
- ``updateUser(id:name:externalId:profileUrl:email:custom:status:type:completion:)``
3136
- ``deleteUser(id:soft:completion:)``
@@ -48,11 +53,6 @@
4853
- ``getUnreadMessagesCount(limit:page:filter:sort:completion:)``
4954
- ``markAllMessagesAsRead(limit:page:filter:sort:completion:)``
5055

51-
### Working with Channels and Users Suggestions
52-
53-
- ``getUserSuggestions(text:limit:completion:)``
54-
- ``getChannelSuggestions(text:limit:completion:)``
55-
5656
### Retrieving Current User Mentions
5757

5858
- ``UserMentionData``

PubNubSwiftChatSDK/PubNubSwiftChatSDK.docc/PubNubSwiftChatSDK.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Our Chat SDK provides a number of out-of-the-box chat features like read receipt
5858
- ``MessageDraftChangeListener``
5959
- ``ClosureMessageDraftChangeListener``
6060
- ``SuggestedMention``
61-
- ``SuggestedMentionsFuture``
61+
- ``FutureObject``
6262
- ``MentionTarget``
6363
- ``MessageElement``
6464
- ``UserSuggestionSource``

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
3737
1. Create or open your project inside Xcode.
3838
2. Navigate to **File -> Add Package Dependencies**.
3939
3. Search for `https://github.com/pubnub/swift-chat-sdk`
40-
4. From the **Dependency Rule** drop-down list, select **Exact**. In the version input field, type `0.10.0-dev`
40+
4. From the **Dependency Rule** drop-down list, select **Exact**. In the version input field, type `0.10.1-dev`
4141
5. Click the **Add Package** button.
4242

4343
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)

Sources/Chat.swift

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ public protocol Chat: AnyObject {
3535
var pubNub: PubNub { get }
3636
/// Object representing current user
3737
var currentUser: ChatUserType { get }
38-
/// The name of the action that represents editing a message
38+
/// A type of action added to your Message object whenever a published message is edited, like "changed" or "modified". The default value is "edited"
3939
var editMessageActionName: String { get }
40-
/// The name of the action that represents deleting a message
40+
/// A type of action added to your Message object whenever a published message is deleted, like "removed". The default value is "deleted"
4141
var deleteMessageActionName: String { get }
42+
/// A type of action you added to your Message object whenever a reaction is added to a published message, like "reacted". The default value is "reactions"
43+
var reactionsActionName: String { get }
4244

4345
/// Initializes the current instance and performs any necessary setup.
4446
///
47+
/// This method must be called before invoking any other operations
48+
/// in order to ensure the SDK is properly initialized.
49+
///
4550
/// - Parameters:
4651
/// - completion: The async `Result` of the method call
4752
/// - **Success**: The initialization succeeded and returns the instance
@@ -50,18 +55,6 @@ public protocol Chat: AnyObject {
5055
completion: ((Swift.Result<Self, Error>) -> Void)?
5156
)
5257

53-
/// Creates a new user.
54-
///
55-
/// - Parameters:
56-
/// - user: A `User` object containing the details of the user to be created.
57-
/// - completion: The async `Result` of the method call
58-
/// - **Success**: The user was successfully created and returns the created user
59-
/// - **Failure**: An `Error` describing the failure
60-
func createUser(
61-
user: ChatUserType,
62-
completion: ((Swift.Result<ChatUserType, Error>) -> Void)?
63-
)
64-
6558
/// Creates a new user with a unique User ID.
6659
///
6760
/// - Parameters:

Sources/ChatConfiguration.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ public class CustomPayloads {
3939
/// If you wish to bypass the custom mapping (e.g. for certain channels), you can fall back to the default by calling the third parameter - `DefaultGetMessageResponseBody` and returning its result
4040
/// Define `getMessagePublishBody` whenever you use `getMessageResponseBody`
4141
var getMessageResponseBody: GetMessageResponseBody?
42-
/// A name of action to add to your Message object whenever a published message is edited
42+
/// A type of action to add to your Message object whenever a published message is edited
4343
var editMessageActionName: String?
44-
/// A name of action to add to your Message object whenever a published message is edited
44+
/// A type of action to add to your Message object whenever a published message is edited
4545
var deleteMessageActionName: String?
46-
/// A name of action to add to your Message object whenever a reaction is added
46+
/// A type of action to add to your Message object whenever a reaction is added
4747
var reactionsActionName: String?
4848

4949
/// Creates a new ``CustomPayloads`` object.
5050
///
5151
/// - Parameters:
5252
/// - getMessagePublishBody: Function that lets Chat SDK send your custom payload structure
5353
/// - getMessageResponseBody: Function that lets Chat SDK receive your custom payload structure
54-
/// - editMessageActionName: A name of action to add to your Message object whenever a published message is edited, like "changed" or "modified. The default value is `"edited"`
55-
/// - deleteMessageActionName: A name of action to add to your Message object whenever a published message is deleted, like "removed". The default value is `"deleted"`
56-
/// - reactionsActionName: A name of action to add to your Message object whenever a reaction is added. The default value is `"reactions"`
54+
/// - editMessageActionName: If present, overrides the default action type to be added to your Message object whenever a published message is edited
55+
/// - deleteMessageActionName: If present, overrides the default action type to be added to your Message object whenever a published message is deleted
56+
/// - reactionsActionName: If present, overrides the default action type to be added to your Message object whenever a reaction is added
5757
public init(
5858
getMessagePublishBody: GetMessagePublishBody? = nil,
5959
getMessageResponseBody: GetMessageResponseBody? = nil,
@@ -158,7 +158,7 @@ public struct ChatConfiguration {
158158
/// Specifies how often the user global presence in the app should be updated. Requires `storeUserActivityTimestamps`
159159
/// to be set to true. The minimum possible value is 60 seconds. If you try to set it to a lower value, you'll get the storeUserActivityInterval must be at least 60000ms error
160160
public var storeUserActivityInterval: Int
161-
/// Specifies if you want to track the user's global presence in your chat app. The user's activity is tracked through `user.lastActiveTimestamp`
161+
/// Specifies if you want to track the user's global presence in your chat app. The user's activity is tracked through ``User/lastActiveTimestamp``
162162
public var storeUserActivityTimestamps: Bool
163163
/// List of parameters you must set if you want to enable sending/receiving mobile push notifications for phone devices, either through Apple Push Notification service (APNS) or Firebase Cloud Messaging (FCM)
164164
public var pushNotificationsConfig: PushNotificationsConfig
@@ -229,7 +229,11 @@ public struct ChatConfiguration {
229229
/// Defines the list of parameters you must set if you want to enable sending/receiving mobile push notifications for phone devices,
230230
/// either through Apple Push Notification service (APNS) or Firebase Cloud Messaging (FCM).
231231
public struct PushNotificationsConfig {
232-
/// The main option for enabling sending notifications
232+
/// The main option for enabling sending notifications. It must be set to `true` if you want a particular client (whether a mobile device, web browser, or server) to send
233+
/// push notifications to mobile devices.
234+
///
235+
/// These push notifications are messages with a provider-specific payload that the Chat SDK automatically attaches to every message.
236+
/// Chat SDK includes a default payload setup for ``deviceGateway`` in every message sent to the registered channels.
233237
public var sendPushes: Bool
234238
/// Refers to the unique identifier assigned to a specific mobile device by a platform's push notification service
235239
public var deviceToken: String?

Sources/ChatImpl.swift

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ extension ChatImpl {
103103
}
104104
}
105105
}
106+
107+
func createUser(
108+
user: UserImpl,
109+
completion: ((Swift.Result<UserImpl, Error>) -> Void)?
110+
) {
111+
chat.createUser(
112+
user: user.user
113+
).async(caller: self) { (result: FutureResult<ChatImpl, PubNubChat.User>) in
114+
switch result.result {
115+
case let .success(createdUser):
116+
completion?(.success(UserImpl(user: createdUser)))
117+
case let .failure(error):
118+
completion?(.failure(error))
119+
}
120+
}
121+
}
106122
}
107123

108124
extension ChatImpl: Chat {
@@ -116,6 +132,7 @@ extension ChatImpl: Chat {
116132
public var currentUser: UserImpl { UserImpl(user: chat.currentUser) }
117133
public var editMessageActionName: String { chat.editMessageActionName }
118134
public var deleteMessageActionName: String { chat.deleteMessageActionName }
135+
public var reactionsActionName: String { chat.reactionsActionName }
119136

120137
public func initialize(completion: ((Swift.Result<ChatImpl, Error>) -> Void)? = nil) {
121138
chat.initialize().weakAsync(caller: self) { (result: WeakFutureResult<ChatImpl, PubNubChat.Chat>) in
@@ -132,22 +149,6 @@ extension ChatImpl: Chat {
132149
}
133150
}
134151

135-
public func createUser(
136-
user: UserImpl,
137-
completion: ((Swift.Result<UserImpl, Error>) -> Void)?
138-
) {
139-
chat.createUser(
140-
user: user.user
141-
).async(caller: self) { (result: FutureResult<ChatImpl, PubNubChat.User>) in
142-
switch result.result {
143-
case let .success(createdUser):
144-
completion?(.success(UserImpl(user: createdUser)))
145-
case let .failure(error):
146-
completion?(.failure(error))
147-
}
148-
}
149-
}
150-
151152
public func createUser(
152153
id: String,
153154
name: String? = nil,

Sources/MessageDraft/MessageDraft.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public protocol MessageDraft {
6262
/// Insert mention into the ``MessageDraft`` according to ``SuggestedMention/offset``, ``SuggestedMention/replaceFrom`` and ``SuggestedMention/target``.
6363
///
6464
/// - Parameters:
65-
/// - mention: A ``SuggestedMention`` that can be obtained from ``MessageDraftStateListener``
66-
/// - text: The text to replace ``SuggestedMention/replaceFrom`` with. ``SuggestedMention/replaceTo`` can be used for example
65+
/// - mention: A ``SuggestedMention`` that can be obtained from ``MessageDraftChangeListener``
66+
/// - text: The text to replace ``SuggestedMention/replaceFrom`` with. ``SuggestedMention/replaceWith`` can be used for example
6767
func insertSuggestedMention(mention: SuggestedMention, text: String)
6868

6969
/// Add a mention to a user, channel or link specified by `target` at the given offset.
@@ -219,7 +219,7 @@ public enum MentionTarget: Equatable {
219219
}
220220
}
221221

222-
/// A potential mention suggestion received from ``MessageDraftStateListener``.
222+
/// A potential mention suggestion received from ``MessageDraftChangeListener``.
223223
///
224224
/// It can be used with ``MessageDraft/insertSuggestedMention(mention:text:)`` to accept the suggestion and attach a mention to a message draft.
225225
public struct SuggestedMention {

0 commit comments

Comments
 (0)