Child pages
  • AddCertificate
Skip to end of metadata
Go to start of metadata

Description

The AddCertificate API allows the Account Owner to add a certificate to be used for authenticating push notifications requests sent to a particular mobile application running on iOS or Android. The AddCertificate operation may only be called over HTTPS. 

 What are Push Notifications?

Apstrata allows a developer to send push notifications to iOS applications by abstracting the Apple Push Notification Service. Similarly, it allows a developer to send push notifications to Android applications by abstracting the Google Cloud Messaging for Android. In other words, apstrata serves as a push notifications provider for iOS and Andriod applications.

Apstrata makes it really simple to enable push notifications for your applications through a REST API. Here are the steps that need to be taken for this purpose:

  1. Create a configuration for a "mobile application" using the "AddCertificate" API (upload the required certificate and password as both Apple and Google require that push notifications requests be authenticated).
  2. Create channels and subscribe device tokens to them (every device has a unique token or identifier) or push notifications to a run-time specified set of devices ("ad-hoc")
  3. Send notifications to a channel (push notifications will be sent to all devices subscribed in the channel) or to the ad-hoc set of tokens

For iOS, each application has a push notifications certificate issued by Apple. For more details on that, please read this tutorial on how to create and add a certificate.

For Android, each application is tied to a Google account/Project. Enabling the Push Notification API and creating a new project is is done here and is documented here.

Specific Request Parameters

(Refer to Common Request Parameters)

Name

Description

Required

Default

Possible Values

apsdb.store

The name of the store in which the channel is created

No

DefaultStore

 

applicationIDAn identifier for the mobile application for which the certificate is to be addedYes  

apsdb_attachments

The certificate file as obtained from Apple. For the case of Android, you need to create a text file that contains the the API Key. This will change to be a plain text in future releases.

Yes

 

 

passwordFor iOS, this field contains the value of the password associated with the certificate. For Android this field is not required.Yes  
developmentIf the certificate you are uploading is a production certificate, set this parameter value to "false", only valid for iOSNotruetrue, false

Specific Response Elements

(Refer to Common Response Elements)

Specific Logical Errors

(Refer to Common Logical Error Codes)

Error

Description

Status Code

INVALID_STORE_NAME

Store name is invalid.

400

STORE_NOT_FOUND

The store was not found

404

PARAMETER_REQUIREDOne of the required parameters is missing400
INVALID_REQUESTThe request is made over HTTP and not HTTPS400
PERMISSION_DENIEDThe request is made by a regular user and not by the account owner403
DUPLICATE_DOCUMENT_KEYThe provided application ID already exists400
INVALID_PARAMETERThe value provided for the platform parameter is not valid or is not supported400

 

Examples

Sample Request

Request URL: http://sandbox.apstrata.com/apsdb/rest/[authenticationkey]/AddCertificate?apsws.time=[timestamp]&apsws.authSig=[signature] 



POST parameters:

apsdb.store = MyStore
applicationId = MyTestApplication
password = mypassword
apsdb_attachments = [certificate_file_as_multi-part]



Sample XML Response

Success XML:

<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd">
    <metadata>
        <requestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</requestId>
        <status>success</status>       
    </metadata>
</response> 



Failure XML:

<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd">
    <metadata 
        <requestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</requestId>
        <status>failure</status>
        <errorCode>[errorCode]</errorCode>
        <errorDetail>[failMsg]</errorDetail>
    </metadata>
</response> 



Sample JSON Response

{"response": {
    "metadata": {
        "requestId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "status": "success"
    }
}} 


  • No labels