/ Platform API
Platform API
    Chat Platform API v3
    Chat Platform API
    Chat Platform API
    Version 3

    Add a registration or device token

    Copy link

    Adds a user's registration or device token to Sendbird Server. Registering tokens to Sendbird server allows sending notification requests to push notification services on behalf of your server. You can pass gcm, huawei, or apns for FCM registration token, HMS device token, or APNs device token, respectively, in the token_type parameter for push notification service you are using. A user can have up to 20 tokens per service and the token that was registered earliest will be deleted before a new one is added when the user already has 20 tokens registered.

    If you need to register the token via your own server, you can do so with FCM registration token and an APNs device token which are generated and registered by Android and iOS client apps through the corresponding SDKs and allow identification of each client app instance on each device.

    Note: For more information on the registration token and device token, visit the Google's FCM page, Huawei's Push kit and Apple's APNs page.


    HTTP request

    Copy link
    POST https://api-{application_id}.sendbird.com/v3/users/{user_id}/push/{token_type}
    

    Parameters

    Copy link

    The following table lists the parameters that this action supports.

    Required
    Parameter nameTypeDescription

    user_id

    string

    Specifies the unique ID of a user.

    token_type

    string

    Specifies the type of a token. Acceptable values are gcm, huawei, and apns for FCM, HMS, and APNS respectively.


    Request body

    Copy link

    The following table lists the properties of an HTTP request that this action supports.

    Required
    Property nameTypeDescription

    gcm_reg_token

    string

    Specifies a registration token for Firebase Cloud Messaging which was formerly known as Google Cloud Messaging.

    huawei_device_token

    string

    Specifies a device token for Huawei Mobile Services.

    apns_device_token

    string

    Specifies a device token for Apple Push Notification Service.

    {
        "gcm_reg_token": "fP7c4oBk_hU:APA91bEzrb3ks301HRvtXxZEdubB_sEhpPFAb0i3cycvd3E9UvFO7ia2uwu2ms7gR-Ra8AmaRNluCT_0frTWBv45jzPvEwEPeNKaNc0iiHnokHAHo0RTzcXcWvrLXmO1Awft_2k7tfi2"
    }
    

    Response

    Copy link

    If successful, this action returns the registered token for push notification service in the response body.

    {
        "token": "fP7c4oBk_hU:APA91bEzrb3ks301HRvtXxZEdubB_sEhpPFAb0i3cycvd3E9UvFO7ia2uwu2ms7gR-Ra8AmaRNluCT_0frTWBv45jzPvEwEPeNKaNc0iiHnokHAHo0RTzcXcWvrLXmO1Awft_2k7tfi2",
        "type": "GCM",
        "user": {
            "user_id": "Chris",
            "nickname": "Christopher",
            "profile_url": "https://sendbird.com/main/img/profiles/profile_46_512px.png",
            "metadata": {
                "font_preference": "times new roman",
                "font_color": "black"
            }
        }
    }
    

    List of response properties

    Copy link
    Property nameTypeDescription

    token

    string

    The registration or device token of the user.

    type

    string

    The type of registration or device token. Valid values are: GCM, HUAWEI, or APNS for FCM, HMS, and APNS respectively.

    user

    nested object

    The user resource which encapsulates information about the specified user.

    In the case of an error, an error object is returned. A detailed list of error codes is available here.