我已经使用Xamarin Forms应用程序中的Azure Notification Hubs为Android和iOS设备设置了推送通知。我可以成功接收到两个平台的通知,但是单击通知后就无法将用户定向到应用程序中的特定页面。
使用Notification Hub安装模板注册设备以接收来自移动应用程序的通知。 GUID / Notification ID是针对数据库中的记录存储的,然后使用NotificationHubClient的SendTemplateNotificationAsync方法与MVC Web应用程序分开触发通知。
我无法找到一种方法来设置通知的意图或单击动作,以便在单击时在应用程序中加载特定页面。有什么方法可以设置变量以在安装过程中添加意图?
//iOS installation
InstallationTemplate installTemplate = new InstallationTemplate()
{
Body = @"{""aps"":{""alert"":""$(messageParam)""}}"
};
IDictionary"<"string, InstallationTemplate">" template =
new `here`Dictionary"<"string, InstallationTemplate">"();
template.Add("template", installTemplate);
Installation installation = new Installation()
{
InstallationId = stringGuid,
Platform = NotificationPlatform.Apns,
PushChannel = token,
Tags = tags,
Templates = template
};
//End iOS installation
//Android installation
InstallationTemplate installTemplate = new InstallationTemplate()
{
Body = @"{" +
"\"notification\" : {" +
"\"body\" : \"$(messageParam)\"," +
"\"title\" : \"$(titleParam)\"," +
"\"icon\" : \"myicon\" }" +
"}"
};
Installation installation = new Installation()
{
InstallationId = stringGuid,
Platform = NotificationPlatform.Gcm,
PushChannel = token,
Tags = tags,
Templates = template
};
//End Android installation
//Sending of notification from web project
await hub.SendTemplateNotificationAsync(templateParams, "$InstallationId:
{" + installationId + "}").ConfigureAwait(false);
//End of send