NOTE: I use parse to send Push notification only, not as a data storage, that it also provides.
So after some time using it I found things as follows
- Requires this first of all.
ParseClient.Initialize('ParseApplicationKey', 'ParseDotNetKey');
. You should put it code first hits, when you first load the applicaiton. ie. startup.cs
or global.asax.cs
This is a one hit thing.
- Sending pushes uses
Installation
class/table in parse.com. You can add your own columns to the class. I added ContactId
so that i could query against the id to send push.
- You need to enable
Client Push Enabled?
before you can send pushes. Otherwise you will get error like Client-initiated push isn't enabled
- Now Sending 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
https://parse.com/docs/dotnet/guide#push-notifications-sending-pushes
For more info https://parse.com/docs/dotnet/guide#push-notifications