Skip to content

Expose 'append' parameter in Pusher::set() for multi-profile push notification support #6102

@danderson-cont

Description

@danderson-cont

Summary

The append parameter for the /_matrix/client/v3/pushers/set endpoint is not exposed through the SDK's Pusher::set() method or the FFI bindings. This parameter is necessary for multi-profile/multi-account support where multiple Matrix accounts on the same device need to share a single APNS/FCM push token.

Use Case

In our iOS app, we support multiple Matrix accounts logged in simultaneously. Each account needs to register for push notifications using the same device push token. Without the append: true flag, registering a pusher for one account removes the pusher for other accounts that share the same pushkey and app_id.

Current Workaround

We currently bypass the SDK and make direct HTTP calls to the Matrix API:

// We have to make direct HTTP calls because the SDK doesn't expose the append flag
let pushersSetURL = homeserverURL.appendingPathComponent("_matrix/client/v3/pushers/set")
var request = URLRequest(url: pushersSetURL)
request.httpMethod = "POST"
// ... manually construct JSON body with "append": true

Technical Details

The append flag already exists in Ruma's PusherPostData:

pub struct PusherPostData {
    pub pusher: Pusher,
    pub append: bool,  // Already available!
}

However, the SDK's convenience method Request::post(pusher) hardcodes append: false, and neither the core SDK nor the FFI bindings expose this parameter.

Proposed Solution

Add the append parameter with a default value of false to preserve backward compatibility:

  1. crates/matrix-sdk/src/pusher.rs - Add append parameter with default:

    pub async fn set(&self, pusher: Pusher, append: bool) -> Result<()> {
        let action = PusherAction::Post(PusherPostData { pusher, append });
        self.client.send(set_pusher::v3::Request::new(action)).await?;
        Ok(())
    }
  2. bindings/matrix-sdk-ffi/src/client.rs - Add append to FFI with default false:

    pub async fn set_pusher(
        &self,
        identifiers: PusherIdentifiers,
        kind: PusherKind,
        app_display_name: String,
        device_display_name: String,
        profile_tag: Option<String>,
        lang: String,
        append: bool,  // Default to false for backward compatibility
    ) -> Result<(), ClientError>

By defaulting append to false, this change preserves the existing behavior for all current consumers while enabling multi-account support for those who need it.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions