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 PublishResult unmarshall(StaxUnmarshallerContext context) throws Exception { PublishResult publishResult = new PublishResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return publishResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("MessageId", targetDepth)) { publishResult.setMessageId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return publishResult; } } } }