private CreatePlatformEndpointResult createPlatformEndpoint( Platform platform, String customData, String platformToken, String applicationArn) { CreatePlatformEndpointRequest platformEndpointRequest = new CreatePlatformEndpointRequest(); platformEndpointRequest.setCustomUserData(customData); String token = platformToken; String userId = null; if (platform == Platform.BAIDU) { String[] tokenBits = platformToken.split("\\|"); token = tokenBits[0]; userId = tokenBits[1]; Map<String, String> endpointAttributes = new HashMap<String, String>(); endpointAttributes.put("UserId", userId); endpointAttributes.put("ChannelId", token); platformEndpointRequest.setAttributes(endpointAttributes); } platformEndpointRequest.setToken(token); platformEndpointRequest.setPlatformApplicationArn(applicationArn); return snsClient.createPlatformEndpoint(platformEndpointRequest); }
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); }
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); }
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(); }
@Override public PlatformEndpoint createPlatformEndpoint(CreatePlatformEndpointRequest request, ResultCapture<CreatePlatformEndpointResult> extractor) { ActionResult result = resource.performAction("CreatePlatformEndpoint", request, extractor); if (result == null) return null; return new PlatformEndpointImpl(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); }
private CreatePlatformEndpointResult createPlatformEndpoint( String customData, String platformToken, String applicationArn) { CreatePlatformEndpointRequest platformEndpointRequest = new CreatePlatformEndpointRequest(); platformEndpointRequest.setCustomUserData(customData); platformEndpointRequest.setToken(platformToken); platformEndpointRequest.setPlatformApplicationArn(applicationArn); return snsClient.createPlatformEndpoint(platformEndpointRequest); }
/** * Performs the <code>CreatePlatformEndpoint</code> action and use a * ResultCapture to retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>PlatformApplication</code> resource, and any conflicting parameter * value set in the request will be overridden: * <ul> * <li> * <b><code>PlatformApplicationArn</code></b> * - mapped from the <code>Arn</code> identifier. * </li> * </ul> * * <p> * * @return The <code>PlatformEndpoint</code> resource object associated with * the result of this action. * @see CreatePlatformEndpointRequest */ PlatformEndpoint createPlatformEndpoint(CreatePlatformEndpointRequest request, ResultCapture<CreatePlatformEndpointResult> extractor);