Skip to content

create_platform_endpoint

create_platform_endpoint(
    platform_application_arn: String,
    token: String,
    *,
    config_overrides: Optional[SNSClientConfig] = None,
    custom_user_data: Optional[String] = None,
    attributes: Optional[MapStringToString] = None,
) -> CreateEndpointResponse

Creates an endpoint for a device and mobile app on one of the supported push notification services, such as GCM (Firebase Cloud Messaging) and APNS. CreatePlatformEndpoint requires the PlatformApplicationArn that is returned from CreatePlatformApplication. You can use the returned EndpointArn to send a message to a mobile app or by the Subscribe action for subscription to a topic. The CreatePlatformEndpoint action is idempotent, so if the requester already owns an endpoint with the same device token and attributes, that endpoint's ARN is returned without creating a new endpoint. For more information, see Using Amazon SNS Mobile Push Notifications.

When using CreatePlatformEndpoint with Baidu, two attributes must be provided: ChannelId and UserId. The token field must also contain the ChannelId. For more information, see Creating an Amazon SNS Endpoint for Baidu.

Parameters:

  • platform_application_arn (String) –

    PlatformApplicationArn returned from CreatePlatformApplication is used to create a an endpoint.

  • token (String) –

    Unique identifier created by the notification service for an app on a device. The specific name for Token will vary, depending on which notification service is being used. For example, when using APNS as the notification service, you need the device token. Alternatively, when using GCM (Firebase Cloud Messaging) or ADM, the device token equivalent is called the registration ID.

  • custom_user_data (Optional[String], default: None ) –

    Arbitrary user data to associate with the endpoint. Amazon SNS does not use this data. The data must be in UTF-8 format and less than 2KB.

  • attributes (Optional[MapStringToString], default: None ) –

    For a list of attributes, see SetEndpointAttributes .

Raises:

Source code in docs_src/capo_sns/_services/sns.py
def create_platform_endpoint(
    self,
    platform_application_arn: "capo_sns.types.string.String",
    token: "capo_sns.types.string.String",
    *,
    config_overrides: Optional[SNSClientConfig] = None,
    custom_user_data: Optional["capo_sns.types.string.String"] = None,
    attributes: Optional[
        "capo_sns.types.map_string_to_string.MapStringToString"
    ] = None,
) -> "capo_sns.types.create_endpoint_response.CreateEndpointResponse":
    """<p>Creates an endpoint for a device and mobile app on one of the supported push notification services, such as GCM (Firebase Cloud Messaging) and APNS. <code>CreatePlatformEndpoint</code> requires the <code>PlatformApplicationArn</code> that is returned from <code>CreatePlatformApplication</code>. You can use the returned <code>EndpointArn</code> to send a message to a mobile app or by the <code>Subscribe</code> action for subscription to a topic. The <code>CreatePlatformEndpoint</code> action is idempotent, so if the requester already owns an endpoint with the same device token and attributes, that endpoint's ARN is returned without creating a new endpoint. For more information, see <a href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using Amazon SNS Mobile Push Notifications</a>. </p> <p>When using <code>CreatePlatformEndpoint</code> with Baidu, two attributes must be provided: ChannelId and UserId. The token field must also contain the ChannelId. For more information, see <a href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePushBaiduEndpoint.html">Creating an Amazon SNS Endpoint for Baidu</a>. </p>

    Args:
        platform_application_arn: <p> <code>PlatformApplicationArn</code> returned from CreatePlatformApplication is used to create a an endpoint.</p>
        token: <p>Unique identifier created by the notification service for an app on a device. The specific name for Token will vary, depending on which notification service is being used. For example, when using APNS as the notification service, you need the device token. Alternatively, when using GCM (Firebase Cloud Messaging) or ADM, the device token equivalent is called the registration ID.</p>
        custom_user_data: <p>Arbitrary user data to associate with the endpoint. Amazon SNS does not use this data. The data must be in UTF-8 format and less than 2KB.</p>
        attributes: <p>For a list of attributes, see <a href="https://docs.aws.amazon.com/sns/latest/api/API_SetEndpointAttributes.html"> <code>SetEndpointAttributes</code> </a>.</p>

    Raises:
        capo_sns.errors.authorization_error_exception.AuthorizationErrorException: <p>Indicates that the user has been denied access to the requested resource.</p>
        capo_sns.errors.internal_error_exception.InternalErrorException: <p>Indicates an internal service error.</p>
        capo_sns.errors.invalid_parameter_exception.InvalidParameterException: <p>Indicates that a request parameter does not comply with the associated constraints.</p>
        capo_sns.errors.not_found_exception.NotFoundException: <p>Indicates that the requested resource does not exist.</p>
        capo_sns.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sns.types.create_platform_endpoint_input.CreatePlatformEndpointInput]",
    ) -> OperationResponse[
        "capo_sns.types.create_endpoint_response.CreateEndpointResponse"
    ]:
        import capo_sns._operations.amazon_simple_notification_service.create_platform_endpoint

        output, http_response = (
            capo_sns._operations.amazon_simple_notification_service.create_platform_endpoint.create_platform_endpoint(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePlatformEndpoint")
    )
    input_: capo_sns.types.create_platform_endpoint_input.CreatePlatformEndpointInput = {
        "platform_application_arn": platform_application_arn,
        "token": token,
    }
    if custom_user_data is not None:
        input_["custom_user_data"] = custom_user_data
    if attributes is not None:
        input_["attributes"] = attributes

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output