I have an android device that is registered to an SNS Platform Application. So it is a platform endpoint (in terms of aws sns). It has subscribed a total of 20 Sns Topics.
If I have another device (Android or Iphone), which is also an SNS platform endpoint, I would like it to be subscribed to same SNS topics.
Basically, I want to subscribe sns topics from one device. And if I install this application to another device, I want all of my subscription to be replicated on that other device as well. I hope I made my self clear.
I am using AWS SDK for Asp.net core.
Thanks for helping out.
Essentially for GCM another device would require another subscription.
The logic below will not work automatically unless you program it in your application.
Basically, I want to subscribe sns topics from one device. And if I install this application to another device, I want all of my subscription to be replicated on that other device as well. I hope I made my self clear.
Please check this example in mobile-platform-endpoint documentation, it is not the same scenario but can be used as reference.
Related
I have developed a device that is able to connect to Google IoT Core through the MQTT protocol, I can publish MQTT messages on telemetry topics (/devices/DEVICE_ID/events).
But I can't figure out how to subscribe my device to a generic topic and send messages from cloud to device via this topic.
Through the console I created the topic MyTestTopic and a subscription MyTestTopic-sub, I guess that somehow I have to subscribe my device to the subscription MyTestTopic-sub, but I don't know to which topic I have to subscribe my device.
I tried to subscribe my device to the following topics:
projects/PROJECT_ID/topics/MyTestTopic
projects/PROJECT_ID/topics/MyTestTopic-sub
/devices/DEVICE_ID/events/MyTestTopic
/devices/DEVICE_ID/events/MyTestTopic-sub
the subscription to these topics seems to be successful, but the device does not receive the messages I send from the console.
Any suggestions please?
I found this thread (Google Cloud IoT - Invalid MQTT publish topic) from 4 years ago, from which I understand that it is possible to subscribe only to some predefined topics, also from the various documents I have read I understand that Google IoT Core allows devices to subscribe to only two topics: /devices/{device-id}/config and /devices/{device-id}/commands/#
Has anything changed since then?
So to be clear, there are two different "topics" in play here. There's the MQTT topics that are described in the docs you found, config and commands. Those are subscribed to on the device using an MQTT client (e.g. Paho MQTT), and sent down to the device from somewhere else via the IoT Core Admin APIs. Then there's Pub/Sub topics. Out of the box, a device using IoT Core does not directly interact with Pub/Sub at all. They publish/receive via the MQTT topics only. So if you register a device with IoT Core, all messages come and go via the MQTT bridge (or HTTPS).
What Gambit support linked to in that github repo is a direct subscription to a Pub/Sub topic (not MQTT). If you look at the Python code, it's establishing proper Google Cloud Credentials via a json token (service account bearer token) that needs to be present on the device or a proxy device. Depending on the device you're using, that may not be possible of course (implementing GCP APIs on a microcontroller is difficult at best).
The easiest way I've seen this done is to implement a Cloud Function that subscribes to a Pub/Sub topic you want to use, and it implements the proper IoT Core Admin calls to push the Pub/Sub messages down to the device as needed. But of course, it all depends on what you're trying to do.
I want to implement a publish/subscribe system inside my Micro service application on top of .NET CORE, and since I've everything built on top of AWS, I started to check SQS.
But from what I understood, SQS is only a queue that doesn't offer me that possibility, so yes I can send and read messages to the queue, but I can't have my clients consuming in real time based on topic and sending messages to every client that is subscribing to that topic, right? That's why they have SNS.
From what I understand in order to use SNS, we will always need to have SQS too, but what I'm not finding is how can I integrate SNS on .NET Core? Is there a good tutorial? Because for SQS there's plenty, but for SNS I'm not finding much.
"I'm not finding is how can I integrate SNS on .NET"
There is a brand new AWS tutorial (only a few days old) that shows how to use the AWS.NET API to create an MVC .NET app that uses the .NET SNS API to write a pub/sub app. This example uses .NET async calls as well.
https://github.com/scmacdon/AWSTracker/tree/master/SNSSampleApp
You're right that you should be looking at a combination of SQS and SNS.
SQS lacks pub/sub and SNS lacks competing consumers.
NServiceBus provides all of the middleware needed to work with both of these underlying services correctly and safely, and in .net core. Here's a simple sample: https://docs.particular.net/samples/sqs/simple/
For more information on how it works, check out the docs:
https://docs.particular.net/transports/sqs/
AFAIK, one key difference between the two is that Appsync is implemented using MQTT and has an emphasis on real-time notification, while SNS is more like a general pub/sub service.
The real-time notification part of Appsync seems to be the right tool for a chat application. However with Appsync, I will not be able to push the notification to users if a connection is not established(?)
I would like to have real-time notification for users regardless the application is opened or not. What is the right tool for this purpose?
Generally, you'll probably have a more "ready-to-use" solution for chat using AppSync, e.g. https://aws.amazon.com/blogs/mobile/building-a-serverless-real-time-chat-application-with-aws-appsync/
Using SNS will probably provide more flexibility at the cost of more of your time wiring up custom code.
You are correct that AppSync doesn't natively support push notifications for background applications; for that, you'd need to wire in something like SNS. You could probably couple AppSync with SNS using an AppSync Lambda resolver.
Depending on your requirements, i.e. if it's not essential that a system notification appears for new messages, you can also query AppSync at app startup time for chat messages that were received while the client was disconnected.
I am using Amazon SNS in order to send push notifications to my React Native mobile app. There is a requirement to cleanup the Topics/Subscriptions in SNS when a given user uninstalls the mobile application or leaves the company (the app will be remotely wiped once the user leaves the department/company).
I've done some research in SNS documentation and found out that it is up to APNS and FCM to notify SNS that a given device token associated to a particular installation of the app on that device is invalid. I do see disabled Endpoints in SNS (meaning that at some point APNS/FCM did provide feedback to SNS about invalid token), however, I need to know how long does it take for this feedback to get delivered to SNS. I tired to uninstall the application from our test iOS device and send a notification through SNS console to the device and the console returned a successful delivery message:
Message published to endpoint
arn:aws:sns:us-east-1:ACCOUNT_ID:endpoint/APNS/APP_ID/ENDPOINT_ID
successfully.
I need to know the time it takes for APNS/FCM to provide the feedback in order to implement a scheduled cleanup process involving deletion of disabled endpoints in SNS.
This is my first question on StackOverflow, I am glad I joined this community!
Thank you for your feedback.
I have a React Native application that works on iOS and Android and I am looking to integrate AWS SNS. I have some questions that I hope people with SNS experience could answer.
From my understanding, AWS SNS is merely a gateway for using GCM (Android) and APNS (iOS)
Is this correct?
If the above is correct, imagine that I have an Android-only app, what's the point of using AWS SNS when I could directly use GCM/Firebase? I can even use Firebase with iOS.
My app needs to allow a single User to send a notification to one or more Users.
Is there an RESTful API I can consume to achieve this?
Or would I need to set up API Gateway and use Lambda functions?
How do I automatically store tokens on SNS?
I read that I have to integrate AWS Cognito for this, or use a Proxy Server.
Edit:
I've managed to write a Node.js server that uses the aws-sdk to communicate with SNS.
Questions corresponding to their above question numbers
Still looking for answers
Still looking for answers
I've written a Node server, I suppose I could embed the aws-sdk code into my React Native app as it can use Node APIs
For question #4 - I used createPlatformEndpoint
I am no specialist but given you have not received an answer yet, I thought I would try to help
you can use AWS SNS to send messages via GCM, but it can do much more, since it's a pub-sub service: for example, if can be configured to receive email complaints from mails sent by AWS SES, and then you get either either a lambda function or a queue (SQS) to receive those actions emitted by SNS, allowing you to act on them
for an Android-app only I don't see a good reason to bother, and even if it was also on iOS, you could configure yourself the sending of push notifications with an if/else in your code. I could argue it's a matter of personal taste, whether you want more configuration in your code vs in the infra-structure (I know the limit can get blurry), but it seems so much easier to keep it in the code that I wouldn't believe a word I said
My app needs to allow a single User to send a notification to one or
more Users.
If it's a user writing to 1 to a few users, like in a messaging app, I would say it's easier to define (and maintain) the logic within your app and iterate over the group of recipients to send the push notifications.
If you're going to have a few people who are going to be followed by thousands of people and needs to write to them, you might have a case for using SNS Topics (each "popular user" can write - maybe via your own api - to an SNS topic to which the "followers" subscribed; keep in mind the max number of topics you can create), as SNS will take care of any scaling issue (it can take time and resources to send a push notification to your 1 million followers)
What you said if you're going to user SNS, otherwise sending a push notification via GCM/FCM is as simple as a POST request.