0

I implement push notification using this totarial. Now I want to send a notification from a website using server C# code or simply with a javascript code but the following link only implement sending notification using node:

    var gcm = require('node-gcm');
var message = new gcm.Message();

//API Server Key
var sender = new gcm.Sender('AIzaSyCDx8v9R0fMsAsjoAffF-P3FCFWXlvwLhg');
var registrationIds = [];

// Value the payload data to send...
message.addData('message',"\u270C Peace, Love \u2764 and PhoneGap \u2706!");
message.addData('title','Push Notification Sample' );
message.addData('msgcnt','3'); // Shows up in the notification in the status bar
message.addData('soundname','beep.wav'); //Sound to play upon notification receipt - put in the www folder in app
//message.collapseKey = 'demo';
//message.delayWhileIdle = true; //Default is false
message.timeToLive = 3000;// Duration in seconds to hold in GCM and retry before timing out. Default 4 weeks (2,419,200 seconds) if not specified.

// At least one reg id required
registrationIds.push('APA91bwu-47V0L7xB55zoVd47zOJahUgBFFuxDiUBjLAUdpuWwEcLd3FvbcNTPKTSnDZwjN384qTyfWW2KAJJW7ArZ-QVPExnxWK91Pc-uTzFdFaJ3URK470WmTl5R1zL0Vloru1B-AfHO6QFFg47O4Cnv6yBOWEFcvZlHDBY8YaDc4UeKUe7ao');

/**
 * Parameters: message-literal, registrationIds-array, No. of retries, callback-function
 */
sender.send(message, registrationIds, 4, function (result) {
    console.log(result);
});

I want to send notification automatically using website or something like this (I want to scheduling sending notification in some times for remind drug time to patient).

In addition, I found this : pubnub for sending notification but unfortunately, it's not work correctly. Pubnub demo doesn't work. How can I do this? Please help me.

10
  • Why do it on the client side of a web page? That seems inconsistent with your goal of having this be automated. Exactly what causes a notification to be sent? Also, please tag your platform. Commented Aug 29, 2016 at 18:20
  • Can you give either of these a try if you're writing C# on the server side? :) 1. Azure Notification Hub 2. PushSharp Commented Aug 29, 2016 at 18:23
  • @EJoshuaS : I receive drug times from an external site in json format and so I need a web page to get drug times and scheduling notification for those times. Commented Aug 29, 2016 at 18:36
  • @EJoshuaS : My platforms : android , IOS and Windows phone. I can not tag more than five! Commented Aug 29, 2016 at 18:37
  • @SwagataPrateek : thank you , I try it now Commented Aug 29, 2016 at 18:37

2 Answers 2

1

Can you give either of these a try if you're writing C# on the server side? :)

  1. Azure Notification Hub
  2. PushSharp
Sign up to request clarification or add additional context in comments.

4 Comments

if I want to send notification on an specific date and time, is it possible with this components?
With azure notification hub . Yes
sorry, another question , azure notification hub have limit in count of notifications send in one day for free accounts?
Im not sure about the pricing as I paid for it. I can have a look and let you know.
0

Personally I'd write a Windows Service that runs a loop to poll the database for any notifications it needs to send out, sends it to Azure Notification Hub or AWS Push Notifications, sleeps for awhile, and then repeats the process.

You don't want to do it on the client side of a web page because the only way the code could ever run is if you had a web browser open all the time pointing to the page.

4 Comments

I receive drug times from an external site in json format and so I need a web page to get drug times and scheduling notification for those times
How do you get the notifications? Is there some kind of web service you're calling? Could you just use HttpClient for that? I'd be very surprised if the only way you can call this is from the client side of a web page; it's a bad solution because the only time the client-side code can run is if you have a browser pointing to it.
@EJoshuaS if you're targeting mobile devices AWS Push Notifications or Azure Notification hub would be just fine. You don't need to catch a notification from a client device. The push notification server for that particular device takes care of it. Windows Phone, iOS and Android has their own Push Notification Providers. Azure or Aws just aggregates the base systems and lets you use it from one single interface. If you're expecting the notification in a web frontend, that's a different case.
Yes, those services are basically just "matchmakers" for vendor-specific push notification services. You'll still need to register on the phone and write a Broadcast Receiver to handle the notification though (in the case of Android), plus you need some way to know when to send out the notification(s) on the server side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.