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

    Add an APNs push configuration

    Copy link

    Registers an APNs (Apple Push Notification service) push configuration for client apps. To send push notifications to iOS devices, you should first register the APNs push configuration. You can also register the configurations on the Sendbird Dashboard under Settings > Chat > Push notifications.

    Note: Now you can use a .p8 file as an authentication token to send push notifications through APNs. Export the token and register it on the Sendbird Dashboard. To learn more about the token-based connection to APNs, visit Apple Developer's Documentation.


    Register a .p12 certificate

    Copy link

    You can register a .p12 certificate file to Sendbird server using the following end point.

    Note: To upload a .p12 file to Sendbird server, you should send a Multipart request.


    HTTP request

    Copy link
    POST https://api-{application_id}.sendbird.com/v3/applications/push/apns
    

    Request body

    Copy link

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

    Properties
    RequiredTypeDescription

    apns_cert

    file

    In a form of the multipart/form-data content type, specifies the name of a .p12 file. Sendbird server scans the content of the file, determines the certificate type, then registers the file as its corresponding type. If you upload a wrong file, you will receive an error.

    OptionalTypeDescription

    apns_cert_env_type

    string

    Specifies the environment type of the .p12 certificate file. Acceptable values are either development or production. There is no need to specify this property when the apns_cert above is specified.

    apns_cert_password

    string

    Specifies the password of the certificate file which has been set during the .p12 file export.

    has_unread_count_badge

    boolean

    Determines whether to badge the client app's icon with the number of a user's unread messages. (Default: true)

    content_available

    boolean

    Determines whether to send a silent notification and perform background update for the app on a user's device. For more information, see the Apple Developer Documentation's Pushing Updates to Your App Silently. (Default: false)

    mutable_content

    boolean

    Determines whether to modify the payload of a push notification before it is displayed on a user's device. For more information, see the Apple Developer Documentation's Modifying Content in Newly Delivered Notifications. (Default: false)

    push_sound

    string

    Specifies the name of a sound file to be played when a push notification is delivered to the client app. The file can be in the app's main bundle or in the Library/Sounds folder of the app's data container.

    apns_type

    string

    (Deprecated) Specifies the certificate type of the .p12 file. Acceptable values are development and production. You should specify either this property or the apns_cert above to inform the server of which certificate type to update.

    HTTPPythoncURL
    Content-Type: multipart/form-data; boundary={your_unique_boundary_string}
    Content-Length: {length of content}
    
    --{your_unique_boundary_string}
    Content-Disposition: form-data; name="has_unread_count_badge"
    
    [boolean]
    --{your_unique_boundary_string}
    Content-Disposition: form-data; name="apns_cert"; filename="push_notification_certificate.p12"
    Content-Type: application/x-pkcs12
    
    [binary contents of the certificate]
    --{your_unique_boundary_string}--
    

    Note: If you can't upload your .p12 file to Sendbird server using the Chat Platform API or the Sendbird Dashboard, it might be some buggy behavior caused by the Keychain Access on your Mac.

    If you use a single CSR file which you previously uploaded to Apple Developer Member Center, you might receive the same CSR file even when requesting separate files for Development and Production stages. To solve this problem, you must generate another CSR file and upload it to Apple Developer Member Center. Then, export a .p12 file again, and upload the new file to Sendbird server.


    Response

    Copy link

    If successful, this action returns the information about the registered APNs push configuration in the response body.

    {
        "push_configurations": [
            {
                "id": "88810c503d843662690bdd60f051a59be41e1847",
                "push_type": "APNS",
                "created_at": 1320245980,
                "apns_cert_env_type": "production",
                "apns_expiration": 1550284380,
                "apns_name": "com.sendbird.reactnative.syncmanager",
                "has_unread_count_badge": 1,
                "content_available": false,
                "mutable_content": false,
                "push_sound": "bell_alarm.swf"
            }
        ]
    }
    

    List of response properties

    Copy link
    Property nameTypeDescription

    push_configurations[]

    array of objects

    A list of either FCM or APNs push configurations.

    push_configurations.(provider).id

    string

    A unique provider ID that identifies the push configuration. This is automatically generated by Sendbird.

    push_configurations.(provider).push_type

    string

    The type of the push configuration.

    push_configurations.(provider).apns_cert_env_type

    string

    The certificate type of the .p12 file. The value of this property can be either production or development.

    push_configurations.(provider).apns_expiration

    string

    The type of the push configuration which is either development or production.

    push_configurations.(provider).apns_name

    string

    The name of the certificate.

    push_configurations.(provider).has_unread_count_badge

    int

    Indicates whether to badge the client app's icon with the number of a user's unread messages. A value of 1 indicates that the number of a user's unread messages is badged with the icon.

    push_configurations.(provider).content_available

    boolean

    Indicates for the client app whether to perform a silent background update on a user's device.

    push_configurations.(provider).mutable_content

    boolean

    Indicates for the client app whether to modify the payload of a push notification before it is displayed on a user's device.

    push_configurations.(provider).push_sound

    string

    The name of a sound file to be played when a push notification is delivered to the client app.


    Register a .p8 file as an authentication token

    Copy link

    You can register a .p8 file as an authentication token to Sendbird server using the following end point.

    Note: To upload a .p8 file to Sendbird server, you should send a Multipart request.


    HTTP request

    Copy link
    POST https://api-{application_id}.sendbird.com/v3/applications/push/apns
    

    Request body

    Copy link

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

    Properties
    RequiredTypeDescription

    apns_key_id

    string

    Specifies the Key ID provided to your authentication key.

    apns_team_id

    string

    Specifies the Team ID of your team in Apple Developer account.

    apns_bundle_id

    string

    Specifies the Bundle ID for your application.

    apns_environment

    string

    Specifies which APNs server to use. Acceptable values are either production or development.

    apns_auth_type

    string

    Specifies which credentials you will use when communicating with APNs. Acceptable values are certificate for a .p12 file and token for a .p8 file.

    OptionalTypeDescription

    has_unread_count_badge

    boolean

    Determines whether to badge the client app's icon with the number of a user's unread messages. (Default: true)

    content_available

    boolean

    Determines for the client app whether to perform a silent background update on a user's device. For more information, see the Apple Developer Documentation's Pushing Updates to Your App Silently. (Default: false)

    mutable_content

    boolean

    Determines for the client app whether to modify the payload of a push notification before it is displayed on a user's device. For more information, see the Apple Developer Documentation's Modifying Content in Newly Delivered Notifications. (Default: false)

    push_sound

    string

    Specifies the name of a sound file to be played when a push notification is delivered to the client app. The file can be in the app's main bundle or in the Library/Sounds folder of the app's data container.

    HTTPPythoncURL
    Content-Type: multipart/form-data; boundary={your_unique_boundary_string}
    Content-Length: {length of content}
    
    --{your_unique_boundary_string}
    Content-Disposition: form-data; name="has_unread_count_badge"
    
    [boolean]
    --{your_unique_boundary_string}
    Content-Disposition: form-data; name="apns_auth_type"
    
    token
    --{your_unique_boundary_string}
    Content-Disposition: form-data; name="apns_key_id"
    
    [key id for the p8 key]
    --{your_unique_boundary_string}
    Content-Disposition: form-data; name="apns_team_id"
    
    [team id from apple developer console]
    --{your_unique_boundary_string}
    Content-Disposition: form-data; name="apns_bundle_id"
    
    [bundle id of your application]
    --{your_unique_boundary_string}
    Content-Disposition: form-data; name="apns_environment"
    
    [PRODUCTION or DEVELOPMENT]
    --{your_unique_boundary_string}
    Content-Disposition: form-data; name="apns_cert"; filename="push_notification_certificate.p8"
    Content-Type: application/pkcs8
    
    [binary contents of the certificate]
    --{your_unique_boundary_string}--
    

    Response

    Copy link

    If successful, this action returns the information about the registered APNs push configuration in the response body.

    {
        "push_configurations": [
            {
                "id": "88810c503d843662690bdd60f051a59be41e1847",
                "push_type": "APNS",
                "created_at": 1320245980,
                "apns_expiration": "",
                "apns_cert_env_type": "production",
                "apns_name": "com.sendbird.reactnative.syncmanager",
                "apns_key_id": "ABC123DEFG",
                "anps_team_id": "DEF123GHIJ",
                "has_unread_count_badge": 1,
                "content_available": false,
                "mutable_content": false,
                "push_sound": "bell_alarm.swf"
            }
        ]
    }
    

    List of response properties

    Copy link
    Property nameTypeDescription

    push_configurations.(provider).apns_key_id

    string

    A unique ID allocated to the registered authentication key. This property appears only when the registered credentials is a .p8 file.

    push_configurations.(provider).apns_team_id

    string

    A unique ID allocated to the team your Apple Developer account belongs to. This property appears only when the registered credentials is a .p8 file.

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