I wrote an Azure function and connected the output to the notification hub to send push notifications using APNS. It works fine while I send a notification to all registered devices, but I don’t know how to use tags to refer to a specific user. If I try to use a tag, I get the error message "Exception when executing function: Functions.SendSinglePushNotification. Microsoft.Azure.WebJobs.Host: Error processing parameter notification after function return: Microsoft.Azure.NotificationHubs: notification. Tag property must be zero.
Here is my code:
#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);
. ?