Skip to content

create_platform_application

create_platform_application(
    name: String,
    platform: String,
    attributes: MapStringToString,
    *,
    config_overrides: Optional[SNSClientConfig] = None,
) -> CreatePlatformApplicationResponse

Creates a platform application object for one of the supported push notification services, such as APNS and GCM (Firebase Cloud Messaging), to which devices and mobile apps may register. You must specify PlatformPrincipal and PlatformCredential attributes when using the CreatePlatformApplication action.

PlatformPrincipal and PlatformCredential are received from the notification service.

  • For ADM, PlatformPrincipal is client id and PlatformCredential is client secret.

  • For APNS and APNS_SANDBOX using certificate credentials, PlatformPrincipal is SSL certificate and PlatformCredential is private key.

  • For APNS and APNS_SANDBOX using token credentials, PlatformPrincipal is signing key ID and PlatformCredential is signing key.

  • For Baidu, PlatformPrincipal is API key and PlatformCredential is secret key.

  • For GCM (Firebase Cloud Messaging) using key credentials, there is no PlatformPrincipal. The PlatformCredential is API key.

  • For GCM (Firebase Cloud Messaging) using token credentials, there is no PlatformPrincipal. The PlatformCredential is a JSON formatted private key file. When using the Amazon Web Services CLI or Amazon Web Services SDKs, the file must be in string format and special characters must be ignored. To format the file correctly, Amazon SNS recommends using the following command: SERVICE_JSON=$(jq @json < service.json).

  • For MPNS, PlatformPrincipal is TLS certificate and PlatformCredential is private key.

  • For WNS, PlatformPrincipal is Package Security Identifier and PlatformCredential is secret key.

You can use the returned PlatformApplicationArn as an attribute for the CreatePlatformEndpoint action.

Parameters:

  • name (String) –

    Application names must be made up of only uppercase and lowercase ASCII letters, numbers, underscores, hyphens, and periods, and must be between 1 and 256 characters long.

  • platform (String) –

    The following platforms are supported: ADM (Amazon Device Messaging), APNS (Apple Push Notification Service), APNS_SANDBOX, and GCM (Firebase Cloud Messaging).

  • attributes (MapStringToString) –

    For a list of attributes, see SetPlatformApplicationAttributes .

Raises:

Source code in docs_src/capo_sns/_services/sns.py
def create_platform_application(
    self,
    name: "capo_sns.types.string.String",
    platform: "capo_sns.types.string.String",
    attributes: "capo_sns.types.map_string_to_string.MapStringToString",
    *,
    config_overrides: Optional[SNSClientConfig] = None,
) -> "capo_sns.types.create_platform_application_response.CreatePlatformApplicationResponse":
    """<p>Creates a platform application object for one of the supported push notification services, such as APNS and GCM (Firebase Cloud Messaging), to which devices and mobile apps may register. You must specify <code>PlatformPrincipal</code> and <code>PlatformCredential</code> attributes when using the <code>CreatePlatformApplication</code> action.</p> <p> <code>PlatformPrincipal</code> and <code>PlatformCredential</code> are received from the notification service.</p> <ul> <li> <p>For ADM, <code>PlatformPrincipal</code> is <code>client id</code> and <code>PlatformCredential</code> is <code>client secret</code>.</p> </li> <li> <p>For APNS and <code>APNS_SANDBOX</code> using certificate credentials, <code>PlatformPrincipal</code> is <code>SSL certificate</code> and <code>PlatformCredential</code> is <code>private key</code>.</p> </li> <li> <p>For APNS and <code>APNS_SANDBOX</code> using token credentials, <code>PlatformPrincipal</code> is <code>signing key ID</code> and <code>PlatformCredential</code> is <code>signing key</code>.</p> </li> <li> <p>For Baidu, <code>PlatformPrincipal</code> is <code>API key</code> and <code>PlatformCredential</code> is <code>secret key</code>.</p> </li> <li> <p>For GCM (Firebase Cloud Messaging) using key credentials, there is no <code>PlatformPrincipal</code>. The <code>PlatformCredential</code> is <code>API key</code>.</p> </li> <li> <p>For GCM (Firebase Cloud Messaging) using token credentials, there is no <code>PlatformPrincipal</code>. The <code>PlatformCredential</code> is a JSON formatted private key file. When using the Amazon Web Services CLI or Amazon Web Services SDKs, the file must be in string format and special characters must be ignored. To format the file correctly, Amazon SNS recommends using the following command: <code>SERVICE_JSON=$(jq @json < service.json)</code>.</p> </li> <li> <p>For MPNS, <code>PlatformPrincipal</code> is <code>TLS certificate</code> and <code>PlatformCredential</code> is <code>private key</code>.</p> </li> <li> <p>For WNS, <code>PlatformPrincipal</code> is <code>Package Security Identifier</code> and <code>PlatformCredential</code> is <code>secret key</code>.</p> </li> </ul> <p>You can use the returned <code>PlatformApplicationArn</code> as an attribute for the <code>CreatePlatformEndpoint</code> action.</p>

    Args:
        name: <p>Application names must be made up of only uppercase and lowercase ASCII letters, numbers, underscores, hyphens, and periods, and must be between 1 and 256 characters long.</p>
        platform: <p>The following platforms are supported: ADM (Amazon Device Messaging), APNS (Apple Push Notification Service), APNS_SANDBOX, and GCM (Firebase Cloud Messaging).</p>
        attributes: <p>For a list of attributes, see <a href="https://docs.aws.amazon.com/sns/latest/api/API_SetPlatformApplicationAttributes.html"> <code>SetPlatformApplicationAttributes</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.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sns.types.create_platform_application_input.CreatePlatformApplicationInput]",
    ) -> OperationResponse[
        "capo_sns.types.create_platform_application_response.CreatePlatformApplicationResponse"
    ]:
        import capo_sns._operations.amazon_simple_notification_service.create_platform_application

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePlatformApplication")
    )
    input_: capo_sns.types.create_platform_application_input.CreatePlatformApplicationInput = {
        "name": name,
        "platform": platform,
        "attributes": attributes,
    }

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