After much research and bumping into the wall a couple of times, it's time to ask some questions.
I'm developing a project which is going to send a message from a web client to a server, then the server should notify multiple clients about the update, which should be done in seconds.
First I thought of using GCM notifications, but the user then have to push the notification in order for some code to run on the client (turning on gps and stuff) but my clients don't have time for clicking the notification when it arrives. So it has to be done without user interaction.
Next thing I thought about was if the android client could listen to the c# server and run code when the server had a new message, but I haven't found a working torturial yet. I was looking into GCM again without push, just messages back and forward, but it's getting difficult to get to work. Also sockets was a option, but it also seems really difficult to get to work and I'm not sure if those options are the way to go.
So I was thinking to just let the android have a background service which is polling either a database or a method on my c# server.
Can anybody give me an idea of what is the right option and maybe a link to a tutorial which is a nice step by step thing.
It could be nice if I had the option to also use it on IOS at a later point.
If i understand correctly, what you are trying to do can be easily done by one of the following or more ways:
1)Use GCM messages with a Payload! When the mobile client receives the Notification it gets the Payload and proceeds on specific actions. http://developer.android.com/google/gcm/adv.html - http://developer.android.com/training/cloudsync/gcm.html#react
2)Use a SyncAdapter and make your app use an AlarmManager which will periodically tell to the app to poll the server through the SyncAdapter and check for new content. Another way of triggering the SyncAdapter is sending a GCM notification like in the first step. http://developer.android.com/training/sync-adapters/creating-sync-adapter.html
Related
I'm looking to send a notification to the user when something changes in my firebase realtime database. I've set up FCM in my Xamarin.Android application. I'm pretty new to Firebase though so I'm a bit confused as to how Database Triggers work. (https://firebase.google.com/docs/functions/database-events)
I'm confused as to whether the functionality for this, ie "OnCreate" or "OnWrite" is written on the Google Cloud Platform or my C# code?
To put it another way, do i either:
Write the code in TypeScript to detect changes in my database then push a notification through FCM, or
Write the code in C# to detect changes, like this: How to get notification in xamarin forms on firebase data change?
Thanks.
To send messages to devices through FCM, you must specify the FCM server* key in your code. As its name implies, this key should only be used in server-side code, or in an otherwise trusted environment. The reason for this is that anyone who has the FCM server key can send whatever message they want to all of your users. If you were to include this key in your client-side C# code, a malicious user can find it and you're putting your users at risk.
Cloud Functions allow you to run small snippets of Node.js code on Google Cloud's servers that run in response to events within your Cloud/Firebase project, such as when a document is written to Cloud Firestore. This code runs on Google's servers, so are the perfect spot to call the FCM API to send notifications.
That's also why you'll see many examples of this approach. But if you have another server-side platform already, it is also totally fine to call the FCM API to send notifications from there.
I'm working on a project where there is android app also included.
there is a webapi call to update the status, from app side they will be sending id and the status.
Here we can update the status in sequence only, that is once the status is changed to A then only it can be changed to B then to C.
It is working fine when network is present.But we have an offline functionality where if three status update call is been done from app when offline-it will send all these three at a time when the system comes online.In this case the system is sending the request in some other order,So the status updation is not happening.
For each request I'm sending the acknowledgement-Issuccess or not.
So is there any way that I can control the sequence of request from .Net side?.
If it can be controlled from the Android side also ,then how?
I know this might be a commonly used scenario,but me and my colleague is pretty new to this ,please give us a hand.!
Assuming your api is rest, it is not wise to track the sequence of requests on the .net part (back-end). It should always be stateless (i.e, in short, you should not keep track of the requests and client state on the server side).
That being said,you could keep track of you status and persist it in the right order (with some kind of order indexing) or push it to a queue mechanism on the app, and later send it when the app is back online in the saved order. If it is working fine when it is online, i don't see a reason why this shouldn't work.
One solution can be Firebase Realtime Database. This article can help you: https://medium.com/step-up-labs/firebase-c-library-5c342989ad18#.t5ao4a6it
Or look into these libraries: FireSharp or FirebaseSharp
I want to have the app i am creating to communicate with my personal android device. As in, my application will be monitoring something on my server, and when something changes it needs to somehow send an option to act or ignore to my phone, and my personal reply (Yes/No) should be send back to the server.
I don't mind any specific protocols. Anything which does not require an app running actively on my phone would be nice, but i am not that great with android native development so if it can be done it should be relatively simply to achieve.
My own idea would be to actually implement Email somehow. So my phone could get an email on my google account (which in turn creates a notification), to which i would send a reply email with my reply. Which in turn will be read out on my server.
The bad part is that i would have to actually open gmail and type out a short message to send back as a reply. So anything easier then that would be a great thing.
I have seen newer android 6 apps use custom buttons in notifications in order for the app to act on, but i have no clue how hard those are to implement and rig to my reply.
Please note that this application is probably nothing that will go public. So i am not going to bother to worry about load or efficiency in the end of it. Since it will be just me and my server.
Any input would be greatly appreciated. The most convenient/easy-to-use method will be marked as the answer.
I think...u can use xml-rpc " http://xmlrpc.scripting.com " for communicating with your server and android app.
I used it in my personal project and found iI to be useful.In my case,I used wordpress as framework so any new updates in my server is notified by this protocol.
I have an email parser application in C# that uses Exchange Web Service where it retrieves incoming emails from the exchange account. Is it possible to have it run real time in the background? Whenever an email arrives, it automatically does its job without me having to click it every time or using a task scheduler. The first plan is task scheduler which I set to run every 5 minutes but I need a more efficient way as this app will receive heaps of emails which will then send a reply back to the sender.
Let me know if I missed some information or if my question is too vague.
Edit:
I did what L-Three suggested but... (please read my reply to BugFinder). The program must only trigger if there is an incoming email. Looping is consuming too much of CPU usage. Is it possible to do this?
I think you are looking for EWS Push Notifications (see https://msdn.microsoft.com/en-us/library/office/dn458791(v=exchg.150).aspx)
If you google for this term, you will find some sample programs, eg http://www.codeproject.com/Articles/73834/EWS-Mail-Notifier.
I want to create a cross platform chat app with backend in c#
I searched for an approach to do so and found that I can do so with http requests to handlers on my server and use the response accordingly.
So till now I made the handlers which can add users, login, send and receive messages using database for storage.
Now I am making android client for that and to get messages for user I need to do http requests at a specific interval (3 seconds).
I feel it is not a good approach to do this. I am making this app for a target audience of nearly 30000. They would be able to chat one on one at a single session.
I just want to know if I am going in right direction or There is far more better ways to make chat apps using backend.
I have heard about wcf but I am not clear with what approach should I take. Please guide me about approaches for chat application.
Edit
An example of little working of any famous chat app like whats app, facebook messenger would be a great help.
Thanks.
You could do it with HTTP, but I'd suggest using TCP instead. There's a very solid base for a C# based TCP server on codereview right here which will outline how to deal with Socket objects how to handle connections properly.
The main perk of going about it this way is that you can connect your client to the server, and the client can be virtually any language, it doesn't have to be C# - as long as the language supports sockets, you'll be fine.
On top of that you can have the client listen to the server, which removes the need of polling the server for new messages every couple of seconds; the client socket will receive data when the server sends it, and you can handle it right away, nearly in real-time, whereas if you'd poll the server for new messages over HTTP every - say 3 seconds - you'll always end up with a delay in your chat service, which is something I think you will want to avoid.
See the code sample on CodeReview I linked above, and read up on how Sockets work in C#, how TCP works in terms of guarantees (TCP guarantees that whatever is sent over it will end up on the other side in the same order, but not necessarily in one packet, etc) and I'm pretty confident you'll be able to make a excellent chat app if you put it all to good use.
Edit: I just noticed the WCF tag on your post. I'd personally steer clear of it for this specific project since you want to achieve cross-platform support; try going as low-level as you possibly can for that.