Receiving pushed messages from web service - windows-phone-7

I am working as part of a team using Android and WP7 to create apps that communicate with a server. So ideally we want a consistent approach to receiving the data from the server.
I currently am using HTTPWebRequest to form a SOAP message and send it to a Java-based web service to receive messages (Adding as a ServiceReference didn't work no matter what I tried) At the moment it's a simple case of receiving the full list of things and just recreate the list each time via DespatchTimer to do periodic calls. But of course periodic pollin is likely to be ratehr battery intensive so not the best apporach for my needs.
I now need to change the code so that changes are pushed rather than polled. The team is looking at XMPP to do this as Android libraries are readily available to do this but I am having trouble finding open source libraries to do this.
Microsoft Push seems available but this appears to require a Microsoft based server side environment to push unless I have misinterpreted this? Or even if push notifications are a sensible way to do this.
So what I would like to know is the approach to handling pushed messages in this scenario which i hope someone out there has had experience in
Thanks

Microsoft Push Notification System [MPNS] does not require a MSFT-based server backend. It simply relays the Push Notifications through carrier or other data channels to subscribing phones. You should be able to make HTTP POST requests to MPNS at the Windows Phone subscriber Channel URI & MPNS would deliver the Push Notifications for you. Your server side can be anything, as long as you able to make the HTTP requests.
A good starting point can be found here.
Hope this helps!

Related

Why do i need GCM or APN?

Why can't the individual app servers directly send notification to their mobile apps ? What is the benefit of having a centralized notification platform ?
From this thread, GCM is a service that helps developers send data from servers to their Android applications on Android devices. Same with APN which is a service for app developers to propagate information to iOS (and, indirectly, watchOS), tvOS, and macOS devices.
You may check these threads:
Why it is preferred to use GCM for push notifications?
Let's say you have 50 applications on your phone that do not use GCM. Each app developer decides it is appropriate to poll their respective backend once a minute.
Since these are all separate applications, each call will likely not happen at the same time as another api call. The biggest kill to battery is when the radio within an android device has to turn back on after being off to make an API call, so multiple calls happening with blocks of time in between drains battery faster (read this article on the radio state machine to better understand why this is https://developer.android.com/training/efficient-downloads/efficient-network-access.html)
In addition, each application will be hitting a separate endpoint. Each time you make an API call, you have to go through the connect process for a given server. With batched api requests or HTTP 2.0, multiple calls going to the same server can be optimized by not having to re-do a handshake or the connect process.
What are some advantages of push notifications?
Wide reach across internet users.
High conversion rates.
Real-time communication.
Push Notifications Explained
Hope this helps!

How to build real time notifications in a distributed project?

I wonder to know which technique and tools I should use to have the ability to send real time notifications to users. Specifically if I build a messaging system.
I can see that modern social networks can send notifications about new messages almost immediately. Even when the user 'A' from one country writes a message to the user 'B' in another country you can see that the user 'A' writes a message and you immediately see it (even if those users live in different continents).
I tried to figure out how it is possible and find any information about this but without success.
The only thing I found out is the technique when we use a Redis or RabbitMQ server with several servers which acts like publishers and subscribers. Our API servers receive new messages then they push a new message in the queue then subscribers receives the messages and if they have an open WebSocket with the recipient they push this message in the WebSocket and a client receives the message.
But it really won't work if you have a distributed project and your clients are connected to the nearest servers in the nearest data center.
The question is: what technologies/techniques/anything we should use to be able to build notifications in a distributed project?
If you develop your distributed app/system using web technologies, you can consider building what is referred to as a Progressive Web App. With PWAs you can add push notifications in a relatively easy way. You could start with a PWA approach, and then decide later on if developing a native app as well (i.e. iOS or Android) would be necessary.
There are many resources to learn and guide you in developing progressive web apps. Check the references I mentioned above, and you can do this codelab as a starting point.

Intercepting PouchDB communications with CouchDB backend

I am considering PouchDB & CouchDb as an alternative to Amazon Cognito Sync for a hybrid mobile app that will need data synced between devices and users. I have pouchdb working in a small sample app that syncs with a local couchdb.
I need to be able to intercept the communications back and forth between the pouchdb and couchdb in Java in order to do things in response to these sync events. Sort of like Amazon Cognito Sync's sync triggers. Also, I keep thinking much like Spring's AOP around.
Since the couchdb has a rest interface, I thought I could point the pouchdb to my application server which has a controller listening for any request with the db name as the base. When a request, from pouchdb comes in the Java Rest Controller can optionally do something, then forward the request to the real rest endpoint of the couchdb and get a response, then optionally do something again, then return the response to the pouchdb.
Does this seem like a feasible solution? I am currently working on trying to get this concept working. Has anyone else done anything like this? Any major pitfalls to this approach? Currently, I'm using Java 8 with Spring Boot & Jersey.
I think the architecture goes like this:
Data is empty everywhere.
Data changes, the device where the data changed pushes via a REST APIs.
Your server "master", send notification GCM or APN to devices.
In your notification listener, you check the type of notification and you sync the data.
If a new device connects to your "list of devices to sync" you send a push notification to sync the data.
Keep a list of connected devices.
The same ideas goes for every device/web browser. You have a local cache that you push to the "master" if it changes locally.
You will have many cases to deal with, and I don't think there are open source projects that offers the same patter as Cognito Sync.
Also think about scalability, devices don't have to pull your "master", the master sends notification to trigger devices to download the data.
You have to deal with diffs, regular checks, and so on ...
Good luck

Windows Phone 7 - how to send files from/to the app?

I'm trying to write the most basic application for windows phone 7 and want to be able to send files (specifically XML in case that changes anything) to my app. Currently I have a WCF service setup so I can send push notifications through it. The problem is that there is a limit on the amount of raw data I can send via a push notification.
My solution to this is to send the initial push notification (either tile or raw) to alert my application that I want to send a file to it and then make the app somehow communicate with a server (everything is on my personal computer btw - I'm just trying to figure out how things work) - from which the app will recieve/download the files.
What is the easiest way to accomplish this? Note that I'm not concerned with security or anything like that.
Clarification - the question is essentialy: how do I transfer files from/to a server to/from the phone? Assume everything else was handled - the app is up and running and the user has given or will give permissions to every possible thing he may give his permission to.
Unfortunately, the total size of a push notification (including HTTP headers) is 1kb. This means that it can't be used to send large amounts of data.
Instead of sending the whole file, send a notification (raw or toast—as appropriate) which should be treated by the application as a trigger to go and retrieve the new file/data/whatever from the server. It may also be worth checking for new messages when your app starts. However, if when you start the app it will notify the server that it is ready to receive raw notifications and such messages will be sent indicating new content is available, it may be unnecessary to add this extra check.
To transfer files to/from the phone you will need to use either HttpWebRequest or WebClient as this is the only way to use HTTP on the device and HTTP is the only protocol currently available to transfer data.
While WebClient may appear to be easier to use than HttpWebRequest it is less flexible and will automatically perform it's callback on the UI thread and if you're downloading files in the background you almost certainly don't want this.
There is no way to transfer files to/from a conencted PC and have them exclusively available to your app.
First of all: you won't be able to do this approach automatically - the user will have to open your app to do that because WP7 SDK doesn't allow your app to run on background/start automatically once a push notification is received.
The only way to communicate with your server, at this point in time, is web services. If I were you, I would check for new information available once the app is started, if there is new info, I would call one or more web services which would return me all the information that I need.
If you want, you can use a timer to check for information periodically.
As I said, it will only work while your app is running (check the app lifecycle if you don't know it yet), WP7 doesn't allow apps to run in background, that is a serious limitation IMHO.
Good Luck,
Oscar
Maybe a little bit off topic but when I was thinking about file sharing in my WP7 app, I found two approaches:
Integrate an app with Dropbox
Use advanced explorer for WP7
You can use the WebClient class and the DownloadStringAsync method in order to download data from a web service .
A good example of this is Scott Guthrie's Twitter app from MIX10 .
George

Web application control through text messages

I want to develop an application that works by receiving text messages from users to gather data. I have no clue where to begin and what to begin with. I can code in Python, C++, PHP and can do Java also.
I was wondering if there can be a personal development setup or framework on which I can develop such application. Releasing it is a different story but I do not have any idea about what setup is needed to develop this application.
Also, how much would this setup cost? Are there open-source or any other cheap alternatives?
There are a lot of services out there that let you receive SMS via a web request. The one I work for Twilio will send you a simple POST request to a URL of your choice containing To, From and Body whenever you receive an incoming message. You can read more about how it works here.
This service offers an api for receiving text messages. You can use the shared number and send it to your server with a keyword or you can pay a monthy fee to have your own dedicated number. So there would be a good place to start.

Resources