【发布时间】:2017-08-15 04:34:03
【问题描述】:
我编写了一个 Azure 函数并将输出连接到通知中心,以使用 APNS 发送推送通知。只要我将通知发送到所有注册的设备,它就可以正常工作,但我不知道如何使用标签来解决特定用户的问题。如果我尝试使用标签,我会收到一条错误消息,提示“执行函数时出现异常:Functions.SendSinglePushNotification。Microsoft.Azure.WebJobs.Host:函数返回后处理参数通知时出错:Microsoft.Azure.NotificationHubs:通知。标记属性应为空。”
到目前为止,这是我的代码:
#r "Microsoft.Azure.NotificationHubs"
#r "Newtonsoft.Json"
using System;
using Microsoft.Azure.NotificationHubs;
using Newtonsoft.Json;using
Microsoft.Azure.WebJobs.Host.Bindings.Runtime;
public static void Run(HttpRequestMessage req, TraceWriter log,Binder
binder, out AppleNotification notification)
{
string user = "Test";
string tagExpression = "Test";
string userTag = req.GetQueryNameValuePairs()
.FirstOrDefault(q => string.Compare(q.Key, "userid", true) == 0)
.Value;
string apnsNotificationPayload = "{\"aps\": {\"alert\": \"Test: (" + user + ")\" }}";
notification = new AppleNotification(apnsNotificationPayload);
}
我试图使用通知 = 新
AppleNotification(apnsNotificationPayload,tagExpression);
但这不起作用。我怎样才能做到这一点?
非常感谢和最好的问候
【问题讨论】:
-
我有一个类似的用例,你在上面有什么进展吗?
标签: ios function azure push-notification