°—軽SNS Mobile Push ®è©±

  • View
    26

  • Download
    5

Embed Size (px)

DESCRIPTION

AWS Casual Talks#1 で話したSNS Mobile Pushの話です

Text of °—軽SNS Mobile Push ®è©±

  • SNS Mobile Push

(@con_mame) AWS / MySQL / Redshift / DataStore etc... http://d.conma.me/ http://facebook.com/conmame Push Notification iPhone / iPad / Android / Kindle APNS / GCM / ADM iOS / AndroidiOS / Android / WP8 / Win Store / Kindle / BlackBerryiOS / Android / WP8 / Win StoreiOS / Android / Kindle SNS Mobile Push 100Push $1 (Push $0.5 + Push $0.5) Topic AWS SNS APNS / APNS_SANDBOX / GCM / ADM Token Feedback Endpoint Arn (e.g. ) (e.g. APNS feedback service) Device token Device token:PlatformEndpoint Arn:Device TokenSNSdevice (SNS )Application Arn: Push Device tokenSNS Device -> API Device -> SNS Token Token Vending Machine SNSEndpoint ArnApplication Arn Device to API 1 Token request 3 Token send 2 Token responseAPI4 Token createAPI5 Endpoint Arn 6 Save Endpoint Arn token DB Mtoken DB S Device to SNS 1 Token request 5 Endpoint Arn 2 Token response3 Token sendAPIAPI4 Endpoint Arn6 Save Endpoint Arn token DB Mtoken DB S 1 Token request 5 Endpoint Arn 2 Token responseApplication Arn AWS Access Key 3 Token send AWS Secret Key APIAPI4 Endpoint Arn6 Save Endpoint Arn token DB Mtoken DB S AWS Access Key / Secret Update IAM (e.g. Create Endpoint) Token Vending Machine 1 Token request 6 Endpoint Arn 2 Token response3 Get Temporary credentialsAPIAPITVM4 Token send5 Endpoint Arn7 Save Endpoint Arn token DB Mtoken DB Shttp://amzn.to/16DN8Rb 1 Token request 6 Endpoint Arn 2 Token response3 Get Temporary credentialsAPIAPI7 Save Endpoint Arn token DB Mtoken DB STVM4 Token send5 Endpoint ArnApplication Arn AWS Tmp Access Key AWS Tmp Secret Keyhttp://amzn.to/16DN8Rb Token Vending Machine (TVM) AWS Security Token Service (STS) STSIAM (Role)( )AWSIdentity / Access Management Service 1 Key1 Application Arn Application ArnSNS Mobile Push Application arn:aws:sns:apnortheast-1:xxxxxxxxxxx:app/APNS/ ApplicationName Key1 Application Arn Application ArnSNS Mobile Push Application AWS Account IDarn:aws:sns:apnortheast-1:xxxxxxxxxxx:app/APNS/ ApplicationName Push # client = AWS::SNS.new.client # response = client.create_endpoint( platform_application_arn: application_arn, token: device_token, custom_user_data: '' ) # endpoint arn endpoint_arn = response[:endpoint_arn] # push (messageJSON) client.publish(target_arn: endpoint_arn, message: 'hoge') PushSNS Topic e.g. ... TopicApplication Arn Endpoint Arn Platform { "default": "", "email": "", "sqs": "", "http": "", "https": "", "sms": "", "APNS": "{"aps":{"alert": "","sound": "default","badge": 2} }", "GCM": "{ "data": { "message": "" } }", "ADM": "{ "data": { "message": "" } }" } Topic (default) 3,000 topics / account 10,000 subscribers / topic Retry Push ArchitectureFeedback Notification feedb ak6 Push to platform 2Manage TokensGenerate message and put queueBatch or App 1 Get Endpoint Arn and user status5 Publish3 dequeue Batch4 Change Message Status Simple Push ArchitectureFeedback Notification feedb ak5 Push to platformManage Tokens4 Publish Batch or App1 Get Endpoint Arn and user status2 Make Push information fileBatch3 Get information file and mark with sent metadata metadataActive? Application Action{"EndpointArn":"arn:aws:sns:ap-northeast-1:xxxx:endpoint/APNS/ApplicatonName/ 7bxxxx98-2xxxf-xxxxbxx4-8cxxxxxx93","EventType":"EndpointUpdated","Resource":"arn:aws: sns:ap-northeast-1:xxxxx:app/APNS/ ApplicatonName","Service":"SNS","Time":"2013-10-27T20:44:12.545Z"} GetEndpointAttributes EnabledfalseTokendevice token4dbxxxxx-aaaa-vvvv-ddddd-xxxxxx Endpoint arnUser Data Push Topic 1Topic()10,000 device topic subscriberTopic devicePush Device token: 11111... Custom User Data CreatePlatformEndpoint params = { 'Action' => 'CreatePlatformEndpoint', 'AWSAccessKeyId' => ACCESS_IDENTIFIER, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => 2, 'Timestamp' => Time.now.iso8601, 'Version' => '2010-03-31', 'CustomUserData' => 'userdata', 'Token' => 'DEVICE TOKEN', 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxx:app/APNS/hoge' }params = { 'Action' => 'CreatePlatformEndpoint', 'AWSAccessKeyId' => ACCESS_IDENTIFIER, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => 2, 'Timestamp' => Time.now.iso8601, 'Version' => '2010-03-31', 'Token' => 'DEVICE TOKEN', 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxx:app/APNS/hoge' } CreatePlatformEndpoint params = { 'Action' => 'CreatePlatformEndpoint', 'AWSAccessKeyId' => ACCESS_IDENTIFIER, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => 2, 'Timestamp' => Time.now.iso8601, 'Version' => '2010-03-31', 'CustomUserData' => 'userdata', 'Token' => 'DEVICE TOKEN', 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxx:app/APNS/hoge' }Endpoitn Arnparams = { 'Action' => 'CreatePlatformEndpoint', 'AWSAccessKeyId' => ACCESS_IDENTIFIER, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => 2, 'Timestamp' => Time.now.iso8601, 'Version' => '2010-03-31', 'Token' => 'DEVICE TOKEN', 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxx:app/APNS/hoge' } CreatePlatformEndpoint params = { 'Action' => 'CreatePlatformEndpoint', 'AWSAccessKeyId' => ACCESS_IDENTIFIER, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => 2, 'Timestamp' => Time.now.iso8601, 'Version' => '2010-03-31', 'CustomUserData' => 'userdata', 'Token' => 'DEVICE TOKEN', 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxx:app/APNS/hoge' }Endpoitn Arnparams = { 'Action' => 'CreatePlatformEndpoint', 'AWSAccessKeyId' => ACCESS_IDENTIFIER, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => 2, 'Timestamp' => Time.now.iso8601, 'Version' => '2010-03-31', 'Token' => 'DEVICE TOKEN', 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxx:app/APNS/hoge' } SenderInvalidParameter Invalid parameter: Token Reason: Endpoint arn:aws:sns:apnortheast-1:xxxx:endpoint/APNS/hoge/xxxx0e-aa2a-35xxe-xxx-xxxxxxxx already exists with the same Token, but different attributes.xxx-yy5-5zz8-b1zz-4aaaa7ccvvvvv SNS Device token CreatePlatformEndpoint params = { 'Action' => 'CreatePlatformEndpoint', 'AWSAccessKeyId' => ACCESS_IDENTIFIER, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => 2, 'Timestamp' => Time.now.iso8601, 'Version' => '2010-03-31',CustomUserData'' => 'userdata','Token' => 'DEVICE TOKEN', 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxx:app/APNS/hoge' } params = { 'Action' => 'CreatePlatformEndpoint', 'AWSAccessKeyId' => ACCESS_IDENTIFIER, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => 2, 'Timestamp' => Time.now.iso8601, 'Version' => '2010-03-31', 'Token' => 'DEVICE TOKEN', 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxx:app/APNS/hoge' } Custom User Data Management Console User Data params = { 'Action' => 'CreatePlatformEndpoint', 'AWSAccessKeyId' => ACCESS_IDENTIFIER, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => 2, 'Timestamp' => Time.now.iso8601, 'Version' => '2010-03-31',CustomUserData '''' =>,'Token' => 'DEVICE TOKEN', 'PlatformApplicationArn' => 'arn:aws:sns:ap-northeast-1:xxxx:app/APNS/hoge' } Metrics Conclusion Push Platform AWS Management ConsoleAPI device Push Thank you!!