我完全不熟悉解析,查看我实际上迷路的文档。
这就是我需要和知道的
- 我有自己的后端,所以我只需要解析以将通知从服务器发送到 iOS、Android 和网页(可选)。
- 用户通过 WCF 服务登录他们的设备。
- 如何向特定用户或多个用户发送推送消息。每个人都有向 channel 发送消息的选项;但是如何从我的 .NET 应用程序构建我想将其发送给的这群人?
- 我找到了这个 How do I send API push message with .Net / Parse.com? (C#)我还下载了 parse.com nuget 包,这让我对 parse.dll 的用途感到困惑。链接中的方法使用 REST 方法发送推送通知。
- 从 parse.com 的网络界面进行推送测试,REST 方法在 iOS 和 Android 上正常工作并被接收。没有在网站上测试过。
最佳答案
注意:我使用解析仅发送推送通知,而不是作为数据存储,它也提供。
所以在使用了一段时间后,我发现了如下情况
- 首先需要这个。
ParseClient.Initialize('ParseApplicationKey', 'ParseDotNetKey');
。当您第一次加载应用程序时,您应该首先点击代码。 IE。startup.cs
或global.asax.cs
这是一击成功的东西。 - 发送推送使用 parse.com 中的
Installation
类/表。您可以将自己的列添加到类中。我添加了ContactId
以便我可以查询发送推送的 id。 - 在发送推送之前,您需要启用
Client Push Enabled?
。否则你会得到类似Client-initiated push isn't enabled
这样的错误
- 现在发送推送通知
// 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
还有其他定位通知的方法 https://parse.com/docs/dotnet/guide#push-notifications-sending-pushes
关于c# - Parse.com 用于从 .NET 框架发送推送通知并在 iOS、Android 和网页上接收,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30501150/