1 00:00:03,330 --> 00:00:07,749 welcome back to Backspace Academy in this lecture I'm going to run through 2 00:00:07,749 --> 00:00:12,910 the simple notification service or SNS for short I'll run through what exactly 3 00:00:12,910 --> 00:00:17,290 is SNS and what are the transport protocols we can use for sending 4 00:00:17,290 --> 00:00:22,540 messages with SNS I'll look at what a message format looks like I'll look at 5 00:00:22,540 --> 00:00:27,940 the mobile push notification service which allows us to send messages via a 6 00:00:27,940 --> 00:00:34,750 push notification to mobile devices I'll look at the setup for Amazon devices 7 00:00:34,750 --> 00:00:39,969 such as Kindle Fire I'll look at the setup for Apple devices and for Google 8 00:00:39,969 --> 00:00:44,640 devices for mobile push notifications 9 00:00:45,030 --> 00:00:50,409 Amazon SNS it's a messaging service that enables the sending of messages up to 10 00:00:50,409 --> 00:00:57,879 256 K to subscribing endpoints or clients the topic name for an SNS topic 11 00:00:57,879 --> 00:01:00,460 is unique and it describes the endpoint for 12 00:01:00,460 --> 00:01:05,650 publishers to post messages to subscribers subscribe to a topic name 13 00:01:05,650 --> 00:01:12,970 and then the subscriber access to topics is determined through an SNS policy so 14 00:01:12,970 --> 00:01:17,290 on that diagram there we can see that a publisher can publish to an SNS topic 15 00:01:17,290 --> 00:01:21,280 whatever that message may be and they can do that through the console through 16 00:01:21,280 --> 00:01:25,360 one of the software development kits or through the command line interface and 17 00:01:25,360 --> 00:01:33,310 that SNS topic will then distribute it to a HTTP endpoint or an email or it 18 00:01:33,310 --> 00:01:40,330 will go to an sqs queue or AWS lambda function you can go to an SMS to a phone 19 00:01:40,330 --> 00:01:45,490 number and you can also go to as a mobile push notification to a mobile 20 00:01:45,490 --> 00:01:55,950 device the transport protocols available for Amazon SNS messages are HTTP or 21 00:01:55,950 --> 00:02:02,590 HTTPS so subscribers can specify a URL as part of their subscription 22 00:02:02,590 --> 00:02:06,910 registration and then those notifications from SNS at them so they 23 00:02:06,910 --> 00:02:14,790 have subscribed to will be delivered via a HTTP HTTP POST call 24 00:02:14,790 --> 00:02:21,900 the specified URL the next one is email or e-mail JSON messages are sent to a 25 00:02:21,900 --> 00:02:27,659 registered address as an email email JSON are sent as a JSON object while 26 00:02:27,659 --> 00:02:34,560 email is sent as a text-based email SQS users can specify and SQS 27 00:02:34,560 --> 00:02:39,090 standard queue as the input unfortunately FIFO queues are currently 28 00:02:39,090 --> 00:02:44,639 not supported for that and we have SMS messages are sent to registered phone 29 00:02:44,639 --> 00:02:50,010 numbers as SMS text messages and that service is not available in every 30 00:02:50,010 --> 00:02:54,120 country of course because not all of those phone numbers will be available 31 00:02:54,120 --> 00:03:01,590 across the whole entire globe the message format for the transport of 32 00:03:01,590 --> 00:03:07,139 messages with email the transport only contains the payload or the message body 33 00:03:07,139 --> 00:03:14,849 but for the others which includes HTTP HTTP email JSON and SQS transport 34 00:03:14,849 --> 00:03:19,769 protocols it includes the message ID which is a universally unique identifier 35 00:03:19,769 --> 00:03:24,120 that is unique for each notification that gets published it'll have a 36 00:03:24,120 --> 00:03:28,979 timestamp it will have the topic aar n which is a topic to which the message 37 00:03:28,979 --> 00:03:34,560 was published to the SNS topic you'll have a type and we'll have an 38 00:03:34,560 --> 00:03:40,260 unsubscribe URL which is a link to an unsubscribe endpoint to prevent 39 00:03:40,260 --> 00:03:44,099 receiving any further notifications it will of course have the message or the 40 00:03:44,099 --> 00:03:49,260 payload of the body and it'll have a subject field if one was included is an 41 00:03:49,260 --> 00:03:54,290 optional parameter and it will have a signature which is a base64 encoded 42 00:03:54,290 --> 00:04:01,260 sha-1 with RSA signature and that is of the message the message ID the subject 43 00:04:01,260 --> 00:04:07,319 if it's present the type timestamp and topic values and signature version which 44 00:04:07,319 --> 00:04:15,720 will be the version of the Amazon SNS signature that was used SNS Mobile push 45 00:04:15,720 --> 00:04:20,759 notifications allow the SNS service to deliver messages directly to mobile 46 00:04:20,759 --> 00:04:26,279 devices as a mobile push notification so the high level steps around it and you 47 00:04:26,279 --> 00:04:29,970 will really need to know just high level steps around this you 48 00:04:29,970 --> 00:04:35,220 for an associate level certification you're going to need to be very much an 49 00:04:35,220 --> 00:04:41,120 expert in this area so the first step is to request credentials from the mobile 50 00:04:41,120 --> 00:04:48,900 platform and then request a token from the mobile platforms so with a DA DM or 51 00:04:48,900 --> 00:04:53,580 the Amazon or Google you get a registration ID and from Apple you will 52 00:04:53,580 --> 00:05:00,510 get a device token from there you can create an SNS platform application 53 00:05:00,510 --> 00:05:06,420 object and then you create an SNS platform endpoint object and then you 54 00:05:06,420 --> 00:05:15,240 publish SNS messages to the mobile endpoint the Amazon device messaging 55 00:05:15,240 --> 00:05:21,030 steps first you need to create a Kindle Fire app with the ADM service enabled 56 00:05:21,030 --> 00:05:27,060 from there you can obtain a client ID and a client secret and then you can 57 00:05:27,060 --> 00:05:33,180 obtain an API key and from there you can obtain a registration ID so once you 58 00:05:33,180 --> 00:05:39,360 have that registration ID you can then use the user with the mobile push 59 00:05:39,360 --> 00:05:45,990 notification service to enable push notifications to ATM and that will send 60 00:05:45,990 --> 00:05:51,120 messages through to the ATM server and those messages will then be forward on 61 00:05:51,120 --> 00:06:00,270 to subscribing a dead ATM clients the Apple push notification service steps 62 00:06:00,270 --> 00:06:04,830 are a little bit more complicated first you need to create an iOS app you then 63 00:06:04,830 --> 00:06:11,400 need to obtain an a kns SSL certificate you then need to obtain the app private 64 00:06:11,400 --> 00:06:15,930 key and then you need to verify the certificate and the app private key and 65 00:06:15,930 --> 00:06:20,520 from there you can obtain a device token and from there you use that again with 66 00:06:20,520 --> 00:06:26,520 the SNS mobile push notification which will then allow SNS to send messages 67 00:06:26,520 --> 00:06:35,529 through to the APNs service and then on to subscribing mobile devices for 68 00:06:35,529 --> 00:06:40,689 cloud messaging for Android you first create a Google API project and then 69 00:06:40,689 --> 00:06:46,149 enable the GCM service and then you obtain a server API key and then obtain 70 00:06:46,149 --> 00:06:52,559 a registration ID from GCM which you then again use with SNS Mobile push 71 00:06:52,559 --> 00:06:58,079 notification to for messages through to Google Cloud messaging and then on to 72 00:06:58,079 --> 00:07:06,429 subscribing mobile devices so that is it for SNS or simple notification service I 73 00:07:06,429 --> 00:07:11,579 look forward to seeing you in future lessons