private void demoNotification(Platform platform, String principal, String credential, String platformToken, String applicationName){ // Create Platform Application. This corresponds to an app on a platform. CreatePlatformApplicationResult platformApplicationResult = createPlatformApplication( applicationName, platform, principal, credential); System.out.println(platformApplicationResult); // The Platform Application Arn can be used to uniquely identify the Platform Application. String platformApplicationArn = platformApplicationResult.getPlatformApplicationArn(); // Create an Endpoint. This corresponds to an app on a device. CreatePlatformEndpointResult platformEndpointResult = createPlatformEndpoint( "CustomData - Useful to store endpoint specific data", platformToken, platformApplicationArn); System.out.println(platformEndpointResult); // Publish a push notification to an Endpoint. PublishResult publishResult = publish(platformEndpointResult.getEndpointArn(), platform); System.out.println("Published. MessageId="+ publishResult.getMessageId()); // Delete the Platform Application since we will no longer be using it. deletePlatformApplication(platformApplicationArn); }
private CreatePlatformApplicationResult createPlatformApplication( String applicationName, Platform platform, String principal, String credential) { CreatePlatformApplicationRequest platformApplicationRequest = new CreatePlatformApplicationRequest(); Map<String, String> attributes = new HashMap<String, String>(); attributes.put("PlatformPrincipal", principal); attributes.put("PlatformCredential", credential); platformApplicationRequest.setAttributes(attributes); platformApplicationRequest.setName(applicationName); platformApplicationRequest.setPlatform(platform.name()); return snsClient.createPlatformApplication(platformApplicationRequest); }
public void demoNotification(Platform platform, String principal, String credential, String platformToken, String applicationName, Map<Platform, Map<String, MessageAttributeValue>> attrsMap) { // Create Platform Application. This corresponds to an app on a // platform. CreatePlatformApplicationResult platformApplicationResult = createPlatformApplication( applicationName, platform, principal, credential); System.out.println(platformApplicationResult); // The Platform Application Arn can be used to uniquely identify the // Platform Application. String platformApplicationArn = platformApplicationResult .getPlatformApplicationArn(); // Create an Endpoint. This corresponds to an app on a device. CreatePlatformEndpointResult platformEndpointResult = createPlatformEndpoint( platform, "CustomData - Useful to store endpoint specific data", platformToken, platformApplicationArn); System.out.println(platformEndpointResult); // Publish a push notification to an Endpoint. PublishResult publishResult = publish( platformEndpointResult.getEndpointArn(), platform, attrsMap); System.out.println("Published! \n{MessageId=" + publishResult.getMessageId() + "}"); // Delete the Platform Application since we will no longer be using it. deletePlatformApplication(platformApplicationArn); }
private CreatePlatformApplicationResult createPlatformApplication( String applicationName, Platform platform, String principal, String credential) { /*Creates a platform application object for one of the supported push notification services, such as APNS and GCM, * to which devices and mobile apps may register. You must specify PlatformPrincipal and PlatformCredential attributes * when using the CreatePlatformApplication action. * * The PlatformPrincipal is received from the notification service. * --------------------------------------------------------------------- * For APNS/APNS_SANDBOX, PlatformPrincipal is "SSL certificate". * For GCM, PlatformPrincipal is not applicable. * For ADM, PlatformPrincipal is "client id". The PlatformCredential is also received from the notification service. * ----------------------------------------------------------------------- * For APNS/APNS_SANDBOX, PlatformCredential is "private key". * For GCM, PlatformCredential is "API key". * For ADM, PlatformCredential is "client secret". * -------------------------------------------------------------------------- * The PlatformApplicationArn that is returned when using CreatePlatformApplication is then used as * an attribute for the CreatePlatformEndpoint action. * For more information, see Using Amazon SNS Mobile Push Notifications . * */ CreatePlatformApplicationRequest platformApplicationRequest = new CreatePlatformApplicationRequest(); Map<String, String> attributes = new HashMap<String, String>(); attributes.put("PlatformPrincipal", principal); attributes.put("PlatformCredential", credential); platformApplicationRequest.setAttributes(attributes); platformApplicationRequest.setName(applicationName); platformApplicationRequest.setPlatform(platform.name()); return snsClient.createPlatformApplication(platformApplicationRequest); }
@Override public PlatformApplication createPlatformApplication( CreatePlatformApplicationRequest request, ResultCapture<CreatePlatformApplicationResult> extractor) { ActionResult result = service.performAction("CreatePlatformApplication", request, extractor); if (result == null) return null; return new PlatformApplicationImpl(result.getResource()); }
public void starterNotification(Platform platform, String principal, String credential, String platformToken, String applicationName, Map<Platform, Map<String, MessageAttributeValue>> attrsMap, String message) { // Create Platform Application. This corresponds to an app on a // platform. CreatePlatformApplicationResult platformApplicationResult = createPlatformApplication( applicationName, platform, principal, credential); System.out.println(platformApplicationResult); // The Platform Application Arn can be used to uniquely identify the // Platform Application. String platformApplicationArn = platformApplicationResult .getPlatformApplicationArn(); // Create an Endpoint. This corresponds to an app on a device. CreatePlatformEndpointResult platformEndpointResult = createPlatformEndpoint( platform, "CustomData - Useful to store endpoint specific data", platformToken, platformApplicationArn); System.out.println(platformEndpointResult); // Publish a push notification to an Endpoint. PublishResult publishResult = publish( platformEndpointResult.getEndpointArn(), platform, attrsMap, message); System.out.println("Published! \n{MessageId=" + publishResult.getMessageId() + "}"); // Delete the Platform Application since we will no longer be using it. deletePlatformApplication(platformApplicationArn); }
/** * Performs the <code>CreatePlatformApplication</code> action and use a * ResultCapture to retrieve the low-level client response. * * <p> * * @return The <code>PlatformApplication</code> resource object associated * with the result of this action. * @see CreatePlatformApplicationRequest */ com.amazonaws.resources.sns.PlatformApplication createPlatformApplication( CreatePlatformApplicationRequest request, ResultCapture<CreatePlatformApplicationResult> extractor);