【问题标题】:Parse.com for sending push notification from .NET framework and receiving on iOS, Android and web pageParse.com 用于从 .NET 框架发送推送通知并在 iOS、Android 和网页上接收
【发布时间】:2015-08-10 15:24:33
【问题描述】:

我对 parse 完全陌生,查看文档时我实际上迷路了。

这就是我需要和知道的

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

【问题讨论】:

  • 你有没有得到这个工作?我还尝试仅将 Parse SDK 用于后端,但所有文档都适用于 Windows Phone 和 Windows RT。我敢肯定,任何信息都会对我们所有人有所帮助。
  • 我确实让它工作得很好,我必须说。我将在今天晚些时候发布我的发现。提示:您必须在文档中挖掘很长时间。

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


【解决方案1】:

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

所以用了一段时间后发现如下

  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. 现在发送推送通知

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-11
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多