【问题标题】:Azure Notification Hub: Does SendTemplateNotificationAsync work for .net CoreAzure 通知中心:SendTemplateNotificationAsync 是否适用于 .net Core
【发布时间】:2018-04-16 02:53:22
【问题描述】:

我在 .Net Core 项目中使用 Azure 通知中心的预览版。在我们的服务器上,我让它为通知中心安装设备。我可以设法将设备安装到后端的通知中心,并能够通过门户向 iOS 设备发送测试。

我尝试在后端代码中添加一行

[HttpPost]
    [Route("TestMessage")]
    public async Task<IActionResult> NotifyByTemplate([FromBody] ApiAttendanceModel model)
    {
        //string jsonMessage, IDictionary<string, string> additionalProperperties, string tagExpressions
        var additionalProperties = new Dictionary<string, string>();
        additionalProperties.Add(Constants.Constant.NotificationMsgName, "asdf");
        var hub = NotificationHubClient.CreateClientFromConnectionString(Constants.Constant.NotificationConnectionString, Constants.Constant.NotificationHubName);
        var result = hub.SendAppleNativeNotificationAsync("{'aps':{ 'alert':'Notification hub test notification' }}");//await hub.SendTemplateNotificationAsync(additionalProperties);

        return Ok(true);
    }

我什至使用了 hub.SendTemplateNotificationAsync。没有通知进来。

我想知道推送通知的预览版工作是否适用于 .net Core。

【问题讨论】:

    标签: azure push-notification notifications .net-core


    【解决方案1】:

    我知道您没有等待 hub.SendAppleNativeNotificationAsync。 这可能会导致您的方法在通知发送之前返回并且您失去上下文的问题。

    【讨论】:

      猜你喜欢
      • 2016-11-13
      • 1970-01-01
      • 2013-10-10
      • 2016-11-08
      • 2021-06-10
      • 1970-01-01
      • 2018-07-29
      • 2019-08-25
      • 2017-03-09
      相关资源
      最近更新 更多