c# - Parse.com 用于从 .NET 框架发送推送通知并在 iOS、Android 和网页上接收

标签 c# asp.net .net parse-platform

我完全不熟悉解析,查看我实际上迷路的文档。

这就是我需要和知道的

  1. 我有自己的后端,所以我只需要解析以将通知从服务器发送到 iOS、Android 和网页(可选)。
  2. 用户通过 WCF 服务登录他们的设备。
  3. 如何向特定用户或多个用户发送推送消息。每个人都有向 channel 发送消息的选项;但是如何从我的 .NET 应用程序构建我想将其发送给的这群人?
  4. 我找到了这个 How do I send API push message with .Net / Parse.com? (C#)我还下载了 parse.com nuget 包,这让我对 parse.dll 的用途感到困惑。链接中的方法使用 REST 方法发送推送通知。
  5. 从 parse.com 的网络界面进行推送测试,REST 方法在 iOS 和 Android 上正常工作并被接收。没有在网站上测试过。

最佳答案

注意:我使用解析仅发送推送通知,而不是作为数据存储,它也提供。

所以在使用了一段时间后,我发现了如下情况

  1. 首先需要这个。 ParseClient.Initialize('ParseApplicationKey', 'ParseDotNetKey');。当您第一次加载应用程序时,您应该首先点击代码。 IE。 startup.csglobal.asax.cs 这是一击成功的东西。
  2. 发送推送使用 parse.com 中的 Installation 类/表。您可以将自己的列添加到类中。我添加了 ContactId 以便我可以查询发送推送的 id。
  3. 在发送推送之前,您需要启用Client Push Enabled?。否则你会得到类似Client-initiated push isn't enabled
  4. 这样的错误
  5. 现在发送推送通知

// 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

更多信息 https://parse.com/docs/dotnet/guide#push-notifications

关于c# - Parse.com 用于从 .NET 框架发送推送通知并在 iOS、Android 和网页上接收,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30501150/

相关文章:

c# - 为什么 C# 中的 Rectangle 类没有 Center() 方法?

c# - 在 asp.net mvc 应用程序中将评论保存到数据库时如何维护评论的格式?

c# - 使用 LINQ to XML 处理数据库

.net - 线程和核心

c# - yield return 仅适用于 IEnumerable<T>?

c# - Adobe Illustrator 中的多段线简化是如何工作的?

javascript - 为网络应用程序实现计时器

c# - Asmx Web 服务如何返回 JSON 而不是 XML?

asp.net - Page_ClientValidate 正在验证多次。

c# - 如何创建具有特定命名空间的 XElement?