Support skipPush and silent system messages in addMembers / removeMembers

Open
#4,190 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
swift
Domain
api, mobile

Research direction

Start with Sources/StreamChat/APIClient/Endpoints/ChannelEndpoints.swift and trace the controller and async Chat state-layer addMembers/removeMembers APIs, including the public SystemMessage type. Verify how request bodies encode skip_push and message.silent, then add coverage for true, false, and default values. Done means all listed API variants support both options, existing calls still compile, and documentation includes the requested example.

Written by the indexing model from the issue text.

Description

The Android SDK allows developers to control push notifications and unread counts when adding or removing channel members by providing:

  • skipPush on addMembers and removeMembers
  • A system Message whose silent property can be set explicitly

The Swift SDK does not currently expose equivalent options. It would be helpful to provide feature parity between the Android and Swift SDKs.

Current Swift API

In Swift SDK 5.7.0, the controller API accepts a system message as a String, but does not expose either skipPush or isSilent:

channelController.addMembers(
    userIds: ["user-1"],
    message: "User joined"
)

channelController.removeMembers(
    userIds: ["user-1"],
    message: "User left"
)

The underlying endpoint request also does not include skip_push:

static func addMembers(
    cid: ChannelId,
    members: [MemberInfo],
    hideHistory: Bool,
    hideHistoryBefore: Date?,
    messagePayload: MessageRequestBody?
) -> Endpoint<EmptyResponse>

static func removeMembers(
    cid: ChannelId,
    userIds: [UserId],
    messagePayload: MessageRequestBody?
) -> Endpoint<EmptyResponse>

Source: ChannelEndpoints.swift

The develop branch introduces a public SystemMessage type, but it still does not allow callers to specify whether the message is silent:

public struct SystemMessage: Equatable, Sendable {
    public var text: String
    public var extraData: [String: RawJSON]

    public init(
        text: String,
        extraData: [String: RawJSON] = [:]
    )
}

Android SDK API

The Android SDK already exposes skipPush for both operations:

public fun addMembers(
    memberIds: List<String>,
    systemMessage: Message? = null,
    hideHistory: Boolean? = null,
    hideHistoryBefore: Date? = null,
    skipPush: Boolean? = null,
): Call<Channel>

public fun removeMembers(
    memberIds: List<String>,
    systemMessage: Message? = null,
    skipPush: Boolean? = null,
): Call<Channel>

The system message can also be marked as silent:

val systemMessage = Message(
    text = "User joined",
    silent = true,
)

channelClient.addMembers(
    memberIds = listOf("user-1"),
    systemMessage = systemMessage,
    skipPush = true,
).enqueue()

channelClient.removeMembers(
    memberIds = listOf("user-1"),
    systemMessage = systemMessage,
    skipPush = true,
).enqueue()

Sources:

Proposed Swift API

Extend SystemMessage so callers can explicitly create a silent system message:

public struct SystemMessage: Equatable, Sendable {
    public var text: String
    public var isSilent: Bool
    public var extraData: [String: RawJSON]

    public init(
        text: String,
        isSilent: Bool = false,
        extraData: [String: RawJSON] = [:]
    ) {
        self.text = text
        self.isSilent = isSilent
        self.extraData = extraData
    }
}

Expose skipPush through the member-management APIs:

public func addMembers(
    userIds: Set<UserId>,
    hideHistory: Bool = false,
    hideHistoryBefore: Date? = nil,
    systemMessage: SystemMessage? = nil,
    skipPush: Bool = false,
    completion: ((Error?) -> Void)? = nil
)

public func removeMembers(
    userIds: Set<UserId>,
    systemMessage: SystemMessage? = nil,
    skipPush: Bool = false,
    completion: ((Error?) -> Void)? = nil
)

The same options should also be available in:

  • The [MemberInfo] overloads
  • The async Chat state-layer APIs
  • Any other public addMembers or removeMembers variants

Example usage:

let systemMessage = SystemMessage(
    text: "User joined",
    isSilent: true
)

channelController.addMembers(
    userIds: ["user-1"],
    systemMessage: systemMessage,
    skipPush: true
)

channelController.removeMembers(
    userIds: ["user-1"],
    systemMessage: SystemMessage(
        text: "User left",
        isSilent: true
    ),
    skipPush: true
)

Expected request mapping

  • skipPush should be serialized as the top-level skip_push property.
  • SystemMessage.isSilent should be serialized as the nested message's silent property.

For example:

{
  "add_members": ["user-1"],
  "skip_push": true,
  "message": {
    "text": "User joined",
    "silent": true
  }
}

Expected behavior

  • skipPush: true prevents push notifications generated by the optional system message.
  • isSilent: true prevents the system message from increasing unread counts or marking the channel as unread.
  • Both properties default to false to preserve existing behavior and source compatibility.

Acceptance criteria

  • addMembers and removeMembers expose skipPush.
  • SystemMessage exposes isSilent.
  • The values are correctly serialized to skip_push and message.silent.
  • Controller and async state-layer APIs both support the options.
  • Existing calls continue to compile without modification.
  • Request-body tests cover true, false, and default values.
  • Documentation includes an example of adding or removing members without push notifications or unread-count changes.

This would bring the Swift SDK member-management API in line with the Android SDK.

Dominant language
Swift
Stars
975
Forks
236
Avg merge
1d 11h
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GetStream/stream-chat-swift

All issues in GetStream/stream-chat-swift

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.