Send Message GCM from C# - c#

I want to create a C# application to send a little message to my Android device.
I've found this article.
For first I've make a win form application and include the functions of the article, after I have registed an API KEY.
I've replaced the API KEY and ID project respectively:
Key for browser apps (with referers) with "YOUR_BROWSER_API_KEY" and "DEVICE_REGISTRATION_ID" with the code that I received from the link:
https://code.google.com/apis/console/#project:**code**:access
The project compiles correctly but when I send data it is returning me the following error:
{"multicast_id":9036041256003980435,"success":0,"failure":1,
"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
Can anyone help me?

From your comments on your question it's not clear that you fully understand what Google Cloud Messaging is for: GCM doesn't send a message that automatically pops up a notification on your device (like a text message would), GCM sends a message to an application you run on your device, and then that application pops up a notification using the data that it received.
If you haven't written an Android app to run on your device yet, you won't be able to use GCM to send anything to it.

Related

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

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.

How do I send push notification to all users except the current one?

I'm creating my first Xamarin app and I have a problem sending push notification to all users but not the current one (via Firebase).
I don't fully understand how it works, I suppose that I have to work with receiver tokens but how can I get them? Because for now I can't even send a notification to a single device.
What I have is an app and a firebase project connected with it, so having server key and sender id list of receivers should be the only thing lacking.

c# WPF app sending message using SKYPE4COMLib, but message is not delivered until recipient open app

I am trying to use SKYPE4COM to send message from a WPF app to iPhone Skype app.
Have done those things:
Install Skype 7.17 in OS Windows 10.
Register SKYPE4COM component.
Add reference to WPF project. (VS2013)
Send message this way:
Skype skype = new Skype();
skype.Attach(skype.Protocol, true);
skype.SendMessage("lucy", "Hello, how are you?");
My issue:
Once I send Message through a button click, the message "Hello, how are you?" is shown at the chat window, but it is always showing sending status, not delivered. Please see below print screen. (Message will be delivered once recipient opens Skype app on iPhone ).
I try to send a message in Skype software instead of my WPF app, the message was sent right away. And the recipient got notification on the iPhone right away. Like this (Please see the second message, was delivered right away)
I am not sure whether I did something wrong in my WPF code or the skype4COMlib is not working with Skype 7.17 version?
Did a lot researches and only get this
http://blogs.skype.com/2013/11/06/feature-evolution-and-support-for-the-skype-desktop-api/
Anyone experiences this issue and has a solution? Thanks in advance.
I tried the same library and code you provided.
When I attached to Skype it showed me a notification with the following link:
https://support.skype.com/en/faq/FA12384/how-does-my-3rd-party-application-work-with-skype-and-how-will-changes-to-skype-impact-my-3rd-party-application
According to this FAQ entry (which contains the link you have in your question as well):
As communicated in this blog post, due to technology improvements we are making to the Skype experience, some features of the API will stop working with Skype for desktop. For example, delivery of chat messages using the API will cease to work.
So it really seems it's not possible to send messages using this library.

Google cloud message(android) and window form(C#)

I want to send message and specify phone number from destop window application(my app on destop) to android application(my app) on mobile device by google cloud message.
So I think I must create a new web service so that I can push message from that service to google cloud message.How can I can do that?
You will need the deviceID of your android device to send a notification to the device. So, you will need to design your web-service to have following functionality:
Receiving the deviceID from the android device.
Sending a message to the device whose deviceID is known to you. Your desktop app will need to talk to your web-service which can in-turn send message to google servers. GCM will handle sending notification.
The part of obtaining the deviceId of a android device to sending message is explained well here:
https://developer.android.com/google/gcm/index.html

Notify windows program from WebServer

At the moment I'm writing a small program in C# for windows 7 which can send notifications over GCM (Google Cloud Messeging) to my Android smartphone. For this I send some data via POST to my WebServer which then pushes the data over GCM to my smartphone. That works great in this way but I also want to send some data to my program from my Smartphone.
My problem now is that I do not know how I can notificy my C# program from my WebServer. I thought about something like this:
Smartphone -> send Data to WebServer -> notify C# program
I do not want to use polling and the GCM client is only for android smartphones. So what do you think is the best way to notify my program that some data is avaible for it? I read something about HTTP streaming but I do not know how it works and have no idea if I can implement it with C#. Or do you have other ideas how I can solve this problem?
SignalR is a good shout but you should also understand the base concepts of socket programming. C# makes it really easy to open a socket and listen for messages. The Microsoft website shows you how to handle a requests synchronously here.
Http is just a message protocol. Once you understand the protocol reading the messages is not too hard. Remember if you are receiving messages from the server it will need to know your IP address etc.

Categories