Do i run functions in c# or google cloud platform? - c#

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.

Related

How to control webapi request sequence either from Android side or asp.net webapi?

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

Implementing phone communication with my C# application

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.

Notification Hubs Message Status

I have some deployed mobile apps that use a backend Web API (not Mobile Service). I added push notifications support using another vendor. Recently...I wanted to check up on Azure Notification Hubs to see if I can also use them for some specific scenario. I am finding out that the documentation has not been updated for a while ...is it me? Is the notification hub the preferred way to send push notifications in Azure?
I am specifically interested in server-side registration. The doc has a special section about that which is nice but it looks quite complicated. Anyway, is there a way to retrieve the status of a message after I send it? For example, if I send a message to target a specific tag, I would like to know how many devices for each platform (i.e. Android, iOS and Windows) it was delivered to and whether the message is still in enqueue, etc.
I just responded to you at https://social.msdn.microsoft.com/Forums/en-US/d420fcc2-7e96-46cc-9dfc-71ea18086b56/notification-hubs-message-status?forum=notificationhubs. Thanks!

How to send a Notification to a specific user, using ChannelUri on a .net backend

I have earlier used windows phone 8.0 with javascript backend, which enabled me to send pushnotifications to specific user based on the stored ChannelUri in my tables.
I have since then moved on to .net since I can then use class' on my client and on the server for verification. However I am not able to find a way of sending to specific users. I am not using NotificationHub, and I am only planning on doing this at later point for broadcasting but for normal communication to other users I would like to send Notifications directed at a user.
I have found this link, that users tags to send to specific users(my users are authenticated). I however would like to know if this is the only solution or if you could also use channelUri and if so how you do it?
Basicly how to send a pudhnotification from server side directed at a specific user?
I had a scenario earlier. My server needs to push content to the connected clients in real time. For this I had used SignalR.
If my understanding is correct, this should suit your situation too.

Polling asp.net MVC server from an Android client

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

Categories