用于从.net框架发送推送通知,并在iOS, Android和网页上接收

本文关键字:Android 网页 iOS 并在 框架 用于 通知 net | 更新日期: 2023-09-27 17:51:05

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

这里,是我需要和知道的

  1. 我有自己的后端,所以我只需要解析从服务器发送通知到iOS, Android和网页(可选)。
  2. 用户通过WCF服务登录设备。
  3. 如何向指定用户或多个用户发送推送消息。有选项发送消息到频道,每个人;但我如何构建这组人,我想从我的。net应用程序发送它?
  4. 我发现这个我如何发送API推送消息与。net/Parse.com?(c#),我还下载了parse.com nuget包,这让我对parse.dll的作用感到困惑。链接中的方法使用REST方法发送推送通知。
  5. 从parse.com的web界面推送测试和REST方法正在工作,并在iOS和Android上接收。没有在网站上测试过。

用于从.net框架发送推送通知,并在iOS, Android和网页上接收

注意:我使用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. 这样的错误
  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