Wednesday, 4 May 2016

AWS SNS (Push)

Overview
  • Supports Mobile and Web push notifications
  • Opt-in
    • Not required by SNS (unlike other subscription types)
    • Required by OS (iOS, Android, Kindle Fire)

Mobile Push notifications
  • Appears on mobile device (notification)
  • Device must have an app installed
  • Received even if the app is not running
  • When you click on such notification the app is typically started on mobile device
  • Cheaper than SMS and better experience
  • Each installed app must be registered with SNS
  • Examples: Pingdom alerts, HipChat notifications

Web Push notifications
  • Notification displayed by the browser
  • Supported by most major browsers

Push Notification Service (PNS)
  • Platforms
    • Apple Push Notification Service (APNS)
    • Google Cloud Messaging for Android (GCM)
    • Amazon Device Messaging (ADM)
    • Windows Push Notification Service (WNS) for Windows Phone 8+ and 8.1+
    • Microsoft Push Notification Service (MPNS) for Windows Phone 7+
    • Baidu Cloud Push for Android in China
  • PNS maintains connection with app@device
  • AWS object ("Application") must be created for each platform
    • CreatePlatformApplication
      • PlatformPrincipal
      • PlatformCredentials

Device Token 
  • Created by PNS 
  • Alternative names
    • Registration Id
  • App receives it when it registers itself with PNS
  • App must send it to the Publisher system (i.e. "our server")
    • POST to Proxy server
    • Cognito - registers directly with SNS
  •  Publisher registers app@device with SNS
    • CreatePlatformEndpoint
  • can be subscribed to any number of topics
  • can be target of direct publish (aka "direct addressing")
  • it is like "phone number" in SMS
  • Registering existing device token with SNS
    • AWS Console (single)
    • CreatePlatformEndpoint (several)
    • AWS Console CSV (bulk)

PNS Device Token Feedback
  • Similar to email "hard-bounce" 
  • SNS automatically handles it
    • Disables the endpoint and notifies about the event
    • GCM returns new token: SNS updates existing

TTL
  • useful for time-sensitive messages
  • how much time in seconds PNS has to deliver the message 
    • e.g. drop if device is turned-off
    • relative to Publish time
  • dwell time
    • time between publish and hand-off to PNS
  • Default: 4 weeks
  • 0 value - if no special meaning for PNS - drop the message

Delivery Status
  • Collect feedback on successful and unsuccessful delivery attempts
  • Specify separate IAM roles for success/failure
  • Specify sampling rate (0,100)
  • AWS writes to CloudWatch Logs
    • Create Metrics/Filters

References
  • https://caniuse.com/#feat=push-api

No comments:

Post a Comment