More Related Content
Similar to [AWSマイスターシリーズ]Amazon SNSモバイルプッシュ通知
Similar to [AWSマイスターシリーズ]Amazon SNSモバイルプッシュ通知 (20)
More from Amazon Web Services Japan
More from Amazon Web Services Japan (20)
[AWSマイスターシリーズ]Amazon SNSモバイルプッシュ通知
- 11. Amazon SNS Mobile Pushはプラットフォーム横断型プッシュ通知
のための中間マネージドサービス
Amazon SNS
Mobile Push
Apple Devices
Google Devices
Amazon Kindle Fire Devices
- 14. メッセージサイズの上限はプラットフォームごと
• Apple Push Notification Service
• 256 bytes
• https://developer.apple.com/library/ios/documentation/NetworkingInternet/Con
ceptual/RemoteNotificationsPG/Chapters/ApplePushService.html
• Amazon Device Messaging
• 6144 bytes
• https://developer.amazon.com/sdk/adm/sending-message.html
• Google Cloud Messaging
• 4096 bytes
• http://developer.android.com/intl/ja/google/gcm/adv.html
- 37. Java BatchアプリからPush
『AWS SDK提供のSNSライブラリでメッセージをPush』
• AWSのCredential(AccessKeyID と SecretAccessKey)でAmazon SNS用のClientオブジェク
トを生成
↓
• Google apiのキー, Device Token, 送信メッセージを定義
↓
• 各プラットフォーム(Android, Apple, Kindle)用オブジェクトを生成
↓
• 送信先デバイスのEndpointを生成
↓
• Endpointにメッセージを送信
- 38. Java BatchアプリからPush
• 各プラットフォーム(Android, Apple, Kindle)用オブジェクトを生成
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());
CreatePlatformApplicationResult platformApplicationResult =
snsClient.createPlatformApplication(platformApplicationRequest);
• Google: GCMでは使用しない
• Apple: Certificate(pem)
• Kindle: Client ID
• Google: apisのキー
• Apple: ClientKey(pem)
• Kindle: Client Secret
- 39. Java BatchアプリからPush
• 送信先デバイスのEndpointを生成
String applicationArn = platformApplicationResult.getPlatformApplicationArn();
CreatePlatformEndpointRequest platformEndpointRequest =
new CreatePlatformEndpointRequest();
platformEndpointRequest.setCustomUserData(customData);
platformEndpointRequest.setToken(platformToken);
platformEndpointRequest.setPlatformApplicationArn(applicationArn);
CreatePlatformEndpointResult platformEndpointResult =
snsClient.createPlatformEndpoint(platformEndpointRequest);
端末から取得した
デバイスのトークン
プラットフォーム情報
- 40. Java BatchアプリからPush
• Endpointにメッセージを送信
PublishRequest publishRequest = new PublishRequest();
Map<String, String> messageMap = new HashMap<String, String>();
messageMap.put(platform.name(), getPlatformSampleMessage(platform));
publishRequest.setTargetArn(platformEndpointResult.getEndpointArn());
publishRequest.setMessageStructure("json");
message = jsonify(messageMap);
publishRequest.setMessage(message);
PublishResult publishResult = snsClient.publish(publishRequest);
messageをセットしてpublish
各プラットフォームを意識せず
統一のインターフェースでシンプルにpush可能
- 43. Amazon SNS
Mobile Push
まとめ:
• クロスプラットフォームプッシュ通知 (Apple, Google, Amazon)
• 1月100万リクエスト無料、以降は100万ごとに$1.00
• 堅牢性と信頼性とスケーラビリティを兼備
• 簡単なトークン管理
参考情報:
• SNSの詳細: http://amzn.to/179ee7r
• はじめ方およびサンプルアプリ: http://amzn.to/15rs1DV