Search in sources :

Example 1 with CreatePlatformEndpointResult

use of com.amazonaws.services.sns.model.CreatePlatformEndpointResult in project krypton-android by kryptco.

the class SNSTransport method registerWithAWS.

public synchronized void registerWithAWS() throws TransportException {
    try {
        AmazonSNSClient client = getClient();
        CreatePlatformEndpointRequest request = new CreatePlatformEndpointRequest().withPlatformApplicationArn(PLATFORM_APPLICATION_ARN).withToken(token);
        CreatePlatformEndpointResult result = client.createPlatformEndpoint(request);
        setEndpointARN(result.getEndpointArn());
        HashMap<String, String> enabledAttribute = new HashMap<>();
        enabledAttribute.put("Enabled", "true");
        SetEndpointAttributesRequest enableRequest = new SetEndpointAttributesRequest().withEndpointArn(endpointARN).withAttributes(enabledAttribute);
        client.setEndpointAttributes(enableRequest);
    } catch (AmazonClientException e) {
        throw new TransportException(e.getMessage());
    }
}
Also used : HashMap(java.util.HashMap) SetEndpointAttributesRequest(com.amazonaws.services.sns.model.SetEndpointAttributesRequest) CreatePlatformEndpointResult(com.amazonaws.services.sns.model.CreatePlatformEndpointResult) AmazonClientException(com.amazonaws.AmazonClientException) CreatePlatformEndpointRequest(com.amazonaws.services.sns.model.CreatePlatformEndpointRequest) AmazonSNSClient(com.amazonaws.services.sns.AmazonSNSClient) TransportException(co.krypt.krypton.exception.TransportException)

Example 2 with CreatePlatformEndpointResult

use of com.amazonaws.services.sns.model.CreatePlatformEndpointResult in project oxAuth by GluuFederation.

the class PushSnsService method createPlatformArn.

public String createPlatformArn(AmazonSNS snsClient, String platformApplicationArn, String token, User user) {
    CreatePlatformEndpointRequest platformEndpointRequest = new CreatePlatformEndpointRequest();
    platformEndpointRequest.setPlatformApplicationArn(platformApplicationArn);
    platformEndpointRequest.setToken(token);
    String customUserData = getCustomUserData(user);
    platformEndpointRequest.setCustomUserData(customUserData);
    CreatePlatformEndpointResult platformEndpointResult = snsClient.createPlatformEndpoint(platformEndpointRequest);
    return platformEndpointResult.getEndpointArn();
}
Also used : CreatePlatformEndpointResult(com.amazonaws.services.sns.model.CreatePlatformEndpointResult) CreatePlatformEndpointRequest(com.amazonaws.services.sns.model.CreatePlatformEndpointRequest)

Example 3 with CreatePlatformEndpointResult

use of com.amazonaws.services.sns.model.CreatePlatformEndpointResult in project ETSMobile-Android2 by ApplETS.

the class CreateEndpointJob method run.

@Override
public void run() {
    verifyPlatformApplication(this.client);
    try {
        CreatePlatformEndpointResult createResult = client.createPlatformEndpoint(new CreatePlatformEndpointRequest().withPlatformApplicationArn(this.applicationArn).withToken(this.token).withCustomUserData(this.userData));
        Log.i("CreateResult", createResult.toString());
    } catch (AmazonClientException ace) {
        ace.printStackTrace();
    }
}
Also used : CreatePlatformEndpointResult(com.amazonaws.services.sns.model.CreatePlatformEndpointResult) AmazonClientException(com.amazonaws.AmazonClientException) CreatePlatformEndpointRequest(com.amazonaws.services.sns.model.CreatePlatformEndpointRequest)

Example 4 with CreatePlatformEndpointResult

use of com.amazonaws.services.sns.model.CreatePlatformEndpointResult in project ETSMobile-Android2 by ApplETS.

the class ArnEndpointHandler method createEndpoint.

private void createEndpoint() {
    try {
        SecurePreferences.Editor editor = securePreferences.edit();
        CreatePlatformEndpointRequest request = new CreatePlatformEndpointRequest().withPlatformApplicationArn(this.applicationArn).withToken(this.token).withCustomUserData(this.userData);
        CreatePlatformEndpointResult createResult = client.createPlatformEndpoint(request);
        Log.i("CreateResult", createResult.toString());
        editor.putString(Constants.SNS_ARN_ENDPOINT, createResult.getEndpointArn()).apply();
    } catch (AmazonClientException ace) {
        ace.printStackTrace();
    }
}
Also used : CreatePlatformEndpointResult(com.amazonaws.services.sns.model.CreatePlatformEndpointResult) AmazonClientException(com.amazonaws.AmazonClientException) CreatePlatformEndpointRequest(com.amazonaws.services.sns.model.CreatePlatformEndpointRequest) SecurePreferences(ca.etsmtl.applets.etsmobile.util.SecurePreferences)

Aggregations

CreatePlatformEndpointRequest (com.amazonaws.services.sns.model.CreatePlatformEndpointRequest)4 CreatePlatformEndpointResult (com.amazonaws.services.sns.model.CreatePlatformEndpointResult)4 AmazonClientException (com.amazonaws.AmazonClientException)3 SecurePreferences (ca.etsmtl.applets.etsmobile.util.SecurePreferences)1 TransportException (co.krypt.krypton.exception.TransportException)1 AmazonSNSClient (com.amazonaws.services.sns.AmazonSNSClient)1 SetEndpointAttributesRequest (com.amazonaws.services.sns.model.SetEndpointAttributesRequest)1 HashMap (java.util.HashMap)1