Can I receive android push notifications via AWS? - android

Essentially, what I would like to do is provision an AWS resource to mimic a user's phone to track push notifications from various applications. For example, the Netflix app will occasionally receive push notifications to inform users about new content being released. Is there any way I could set up a service via AWS (maybe an EC2 instance) to receive these notifications from multiple applications (say I want to receive push notifications from Hulu and Netflix, e.g.) and log them without the need to actually have these applications installed on a physical device. Is this possible? Any advice would be greatly appreciated.

You'll need to be running Android or iOS, to receive push notifications. So, you're looking at physical mobile devices, or emulated devices.
AWS Device Farm is one option. It is more intended for short, ephemeral use, though. Please consider the Pricing and FAQ while considering this solution. If you'll use a device full-time, consider a private device.
Another option is to run an Android or iOS emulator on a physical machine. Android notifications do arrive on the emulator, although with very poor reliability, in my experience. You could run on Android emulator on an EC2 host, or in an EC2 Container.
The most interesting aspect of your project is how to read/process the incoming notification data, once you have it, though. I recommend to start with this aspect of the problem.

Related

Android app that alerts other android devices nearby

So I am trying to develop an idea that has two core apps -
The user
The "alerter"
Basically, the alerter sends out a message that is received by all the phones with the app made for the users, but within a specific radius and not all. Any old programs I can look up into? or any tips, ideas? I'm literally new to the android coding world.
Your help is highly appreciated. Thanks :)
There are numerous ways that could be done, including:
Bluetooth detection
this is not feasible until Android supports becoming a Bluetooth Low Energy transmitter
WiFi detection
the devices must be on same access point to have network connectivity with each other
Server-side
All devices update a common server with their location
Devices can then query server for (reported) nearby devices
Server can also push new devices using GCM or Push IO
You could maybe start by looking for apps that do this sort of thing already. One is the instant-messaging app WeChat, and there are also some dating apps that allow users to make contact with nearby potentials.
Also read Find nearby users of an app (iPhone and Android)
I think you should start with Google Cloud Messaging:
Google Cloud Messaging for Android (GCM) is a service that allows you
to send data from your server to your users' Android-powered device,
and also to receive messages from devices on the same connection. The
GCM service handles all aspects of queueing of messages and delivery
to the target Android application running on the target device. GCM is
completely free no matter how big your messaging needs are, and there
are no quotas.

Push service implementetion on Android devices

First of all, I know GCM service and I have questions about it too.
If I want to implement a push service, is this the right way; Server waits for connections, Android client connects server and waits for data all the time. So server can send data anytime. Connection is always open with keep alive messages.
About GCM;
Is GCM uses this logic?
Is GCM works on all Android devices? I mean is it guaranteed that if a device using Android OS, it also supports this Google service?
If GCM is not a guaranteed service on Android, how should I handle the case that there is no GCM support on device. Or is this a negligible case?
Is GCM uses this logic?
Generally yes, though bear in mind that there are a lot more details.
is it guaranteed that if a device using Android OS, it also supports this Google service?
No. It is only going to be on devices that legitimately have the Play Store and the rest of Google's proprietary app suite. It will not be on the Kindle Fire, the OUYA, or other devices that are using Android purely from the open source project.
how should I handle the case that there is no GCM support on device
Amazon has a GCM equivalent for the Kindle Fire series, IIRC.
Beyond that, since GCM is not a guaranteed delivery service, you need a fallback plan even for "normal" Android devices.
For example, let's suppose that you are writing an app to show news headlines to the user. In the absence of any push notification, you poll for new headlines every four hours, or when the user presses a "refresh" button in the UI. With GCM, your server can push down headlines as they arrive, which your app can pick up. This gives users on "normal" devices fresher data, but still covers cases where you miss some GCM messages or for devices that do not support GCM.
Adding to what CommonsWare mentions about GCM, you may want to look at MQTT as another pub/sub mechanism; It works on any device that can run Java. Here is a link where I try to explain how it works.
That links applies to LAN messaging but it works over the internet as well. It is the mechanism that the Facebook chat app uses. On that link you will find another link to a git where I show MQTT in use on a simple home automation project. If you have any questions, I can try to answer them.

Push messages do not come when on 3G?

I implemented push notification system and I noticed that push messages do not ever come when I am on 3G or 4G (mobile Internet).
When I connect to wifi, they come regularly.
Is this behavior bound to Android OS or we can write a code to change it?
I implemented Parse.com 3rd party library. Regardless of myself, I noticed that push messages from other apps do not come unless I am connected to wifi.
If you see the same behavior with stuff from Google (Gmail, Google Play app updates, etc.), then the problem lies with your phone or carrier. If the Google stuff works (they use what amounts to GCM), then your problem lies with Parse.com and whatever the other apps are using for push.
GCM (and the C2DM precursor) work over mobile data or WiFi. It is a bit tricky to implement a push system as a third-party library, which is why I recommend firmware solutions (GCM, Amazon's just-announced Kindle Fire equivalent, etc.). In particular, maintaining a mobile data connection to the push server, with enough heartbeats to keep the connection alive without really draining the battery, is difficult to get right, particularly given subtle mobile carrier or device variations. Google has more experience with this than do most firms, and Amazon only has to worry about a handful of Kindle Fire models.

Can I simulate a GCM / APNS client device without using a full emulator?

I have an app that needs to push out notifications to thousands of devices up to a few times per day. I'd like to be able to run tests against my server code without actually sending my users anything.
Is there a library in any language that will let me connect to either APNS or GCM as a client without using a full device emulator? I just want to see the network traffic arrive from the server, I don't need to test the app itself on a large scale.
-- EDIT --
One of my goals is to be able to test sending to devices with different configurations without needing to have actual users meeting that need. For example, I'd like to programmatically create and register X devices in each of the timezones and then be able to send notifications to those transient devices in a test scenario. Since I don't have users in a lot of timezones, being tied to real devices (or having to spin up heavy emulators) for testing is a hindrance.
Thanks!
For GCM does the 'dry_run' field in the messsage, (see this page) suit your purposes? It allows you to send a message from your client to the GCM server without it going out to the actual phones/devices.

How does a push notification system works like on Y! Mail app?

I installed today from Market, the Yahoo Mail application and I was reading it offers push message notification technique. Indeed it works, as I got exactly the same moment the alert on my desktop computer and my mobile mail client.
How is it accomplished?
There already is another question discussing how to implement push notification without the cloud to device messaging in older system.
There are several frameworks that give you push abillity. They all require a running a small background thread that is polling a server at a very short interval(Bad for data rate and battery) or keep an open connection to a server that is kept alive somehow and the client is notified every time a new message is waiting on the server.
Have a look at the question and maybe choose on of the mentioned frameworks, the frameworks will reuse the same service for all applications that are installed on the phone using the same framework and therefore save battery and general system usage.
Soon, you will be able to use the Cloud-to-Device Messaging (C2DM) system, though it will require Android 2.2 or higher. You might also want to watch the Google I|O 2010 conference presentation on it, which gives a few clues as to how they implemented it.
Without installing the app, setting up my router to capture packets, and doing some packet inspection I can't tell you exactly how they do it. At the lowest level it's as simple as keeping an open TCP connect to a remote server and having the server sending the client a packet when it needs to do something. My educated guess on the specific way they are doing it is either with IMAP IDLE, or XMPP.

Categories

Resources