essai de la notification GCM
This commit is contained in:
parent
776e0a0361
commit
8e96622fba
3 changed files with 43 additions and 21 deletions
9
sendmsg/NuGet.Config
Executable file
9
sendmsg/NuGet.Config
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
||||||
|
<clear />
|
||||||
|
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||||
|
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
||||||
|
|
@ -14,12 +14,27 @@ namespace MessageSender
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
var reg_id= "eRSVBXTxiyk:APA91bE1NRs6LWBq9O3ACBV5g4B8D2ANwS9UjpPkwYFYWtv6NeTuSzBb6ZBhOFx_gbh9AbSgZ7uHETOPp26ahhJY74i55f7gULgaQR7-MV5CeaBYANfKcVgqQ5GTsb2zMCS_2MIUVy3Q";
|
||||||
var jGcmData = new JObject();
|
var jGcmData = new JObject();
|
||||||
var jData = new JObject();
|
var jNotification = new JObject();
|
||||||
|
jNotification.Add("body","a body");
|
||||||
|
jNotification.Add("title",MESSAGE);
|
||||||
|
jNotification.Add("icon","icon");
|
||||||
|
jGcmData.Add("to",reg_id);
|
||||||
|
jGcmData.Add("notification",jNotification);
|
||||||
|
|
||||||
jData.Add("message", MESSAGE);
|
/* "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
|
||||||
|
"notification" : {
|
||||||
|
"body" : "great match!",
|
||||||
|
"title" : "Portugal vs. Denmark",
|
||||||
|
"icon" : "myicon"
|
||||||
|
}
|
||||||
|
var jData = new JObject();
|
||||||
|
jData.Add("message", MESSAGE);
|
||||||
jGcmData.Add("to", "/topics/global");
|
jGcmData.Add("to", "/topics/global");
|
||||||
jGcmData.Add("data", jData);
|
jGcmData.Add("data", jData);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
var url = new Uri("https://gcm-http.googleapis.com/gcm/send");
|
var url = new Uri("https://gcm-http.googleapis.com/gcm/send");
|
||||||
try
|
try
|
||||||
|
|
@ -33,7 +48,7 @@ namespace MessageSender
|
||||||
"Authorization", "key=" + API_KEY);
|
"Authorization", "key=" + API_KEY);
|
||||||
|
|
||||||
Task.WaitAll(client.PostAsync(url,
|
Task.WaitAll(client.PostAsync(url,
|
||||||
new StringContent(jGcmData.ToString(), Encoding.Default, "application/json"))
|
new StringContent(jGcmData.ToString(), Encoding.UTF8, "application/json"))
|
||||||
.ContinueWith(response =>
|
.ContinueWith(response =>
|
||||||
{
|
{
|
||||||
Task.Run ( async () => {
|
Task.Run ( async () => {
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,28 @@
|
||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
|
"description": "ConsoleApplication Console Application",
|
||||||
|
"authors": [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"projectUrl": "",
|
||||||
|
"licenseUrl": "",
|
||||||
"compilationOptions": {
|
"compilationOptions": {
|
||||||
"emitEntryPoint": true
|
"emitEntryPoint": true
|
||||||
},
|
},
|
||||||
"tooling": {
|
"tooling": {
|
||||||
"defaultNamespace": "sendmsg"
|
"defaultNamespace": "ConsoleApplication"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
|
"Newtonsoft.Json": "9.0.1",
|
||||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
|
"System.Net.Http": "4.1.0"
|
||||||
"System.Net.Http": "4.1.0",
|
|
||||||
"Newtonsoft.Json": "9.0.1"
|
|
||||||
},
|
},
|
||||||
"commands": {
|
"commands": {
|
||||||
"web": "Microsoft.AspNet.Server.Kestrel"
|
"ConsoleApplication": "ConsoleApplication"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnx451": {},
|
"dnx451": {}
|
||||||
"dnxcore50": {}
|
}
|
||||||
},
|
}
|
||||||
"exclude": [
|
|
||||||
"wwwroot",
|
|
||||||
"node_modules"
|
|
||||||
],
|
|
||||||
"publishExclude": [
|
|
||||||
"**.user",
|
|
||||||
"**.vspscc"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue