Parse.com to send push notification from .NET framework and receive it on iOS, Android and webpage

I am completely unfamiliar with the syntax and am looking at the documentation that I am really lost.

This is what I need and know

  • I have my own backend, so I just need to parse sending notifications from the server on iOS, Android, and a webpage (optional).
  • Users register to their devices through the WCF service.
  • How to send a push message to a specific user or multiple users. There are options for sending a message to channels, everyone; but how do I create this group of people that I want to submit from my .NET application?
  • I found this How to send a push API message from .Net / Parse.com? (C #) and I also downloaded the parse.com nuget package which was making me confused as to what parse.dll is for . The method in the link uses the REST method to send the push notification.
  • Push test from parse.com web interface and REST method works and is accepted on iOS and Android. Not tested on the site.
+3


source to share


1 answer


NOTE. I am using parsing to send push notification only, not as the data store it also provides.

So after a while using it I found this:

  • This is required first of all. ParseClient.Initialize('ParseApplicationKey', 'ParseDotNetKey');

    ... Before the first download of the application, you must put it in the first hits. i.e. startup.cs

    or global.asax.cs

    It's one thing.
  • Sending push uses Installation

    class / table in parse.com. You can add your own columns to the class. I added ContactId

    so that I can request an id to send push.
  • You need to enable Client Push Enabled?

    it to send push. Otherwise, you will get an error likeClient-initiated push isn't enabled

  • Now Send push notification

// sending to all with only alert message
var parsePush = new ParsePush();
parsePush.Alert="hi";
await parsePush.SendAsync();

// sending to all with your own data
parsePush.Data= new Dictionary<string, object>
            {
                {"alert", message},// this is replacement for parsePush.Alert
                {"sound", "notify.caf"},// for ios
                {"badge", "Increment"}// for ios notification count increment on icon
            };
await parsePush.SendAsync();
// Sending with custom data, you can add your own properties in the 
// dictionary and send, which will be received by the mobile devices
{"reference_type", referenceType}// add to dictionary
{"reference_id", referenceType}

      




// adding query/conditions 
int[] smartusers={1,2,3,4,5};
parsePush.Query = new ParseQuery<ParseInstallation>()
          .Where(i => smartusers.Contains(i.Get<int>("ContactID")));
// ContactID is a propery in ParseInstallation, that i added

      

There are other methods for targeting notifications too https://parse.com/docs/dotnet/guide#push-notifications-sending-pushes

For more information https://parse.com/docs/dotnet/guide#push-notifications

0


source







All Articles