Cordova 通过Android处理推送通知';s状态栏
如何设置推送通知的格式,使其在状态栏上显示时可以利用本地通知的构造—显示文本和隐藏数据 行为:当移动应用程序未运行时,推送通知显示在设备的状态栏上。当用户单击状态栏上的通知时,通知消失,应用程序打开。虽然这是可以接受的行为,但原始推送通知的格式不允许用户在状态栏上查看。如何格式化推送通知,使其与状态栏(本地通知)查看更兼容?换句话说,隐藏数据但显示用户可读的文本 插件:Cordova 通过Android处理推送通知';s状态栏,cordova,azure,push-notification,azure-notificationhub,localnotification,Cordova,Azure,Push Notification,Azure Notificationhub,Localnotification,如何设置推送通知的格式,使其在状态栏上显示时可以利用本地通知的构造—显示文本和隐藏数据 行为:当移动应用程序未运行时,推送通知显示在设备的状态栏上。当用户单击状态栏上的通知时,通知消失,应用程序打开。虽然这是可以接受的行为,但原始推送通知的格式不允许用户在状态栏上查看。如何格式化推送通知,使其与状态栏(本地通知)查看更兼容?换句话说,隐藏数据但显示用户可读的文本 插件: 推送通知:phonegap插件推送本地通知 本地通知:de.appplant.cordova.plugin.Local-No
- 推送通知:phonegap插件推送本地通知
- 本地通知:de.appplant.cordova.plugin.Local-Notification
string xml = "<ACTION>Add</ACTION>" +
"<UserId>" + ut.UserId + " </UserId>";
Dictionary<string, string> templateParams = new Dictionary<string, string>();
templateParams["messageParam"] = xml;
try
{
NotificationOutcome result = await
hub.SendTemplateNotificationAsync(templateParams, tagId);
config.Services.GetTraceWriter().Info(result.State.ToString());
return result;
}
谢谢您的帮助。下面是我的解决方案 服务器端:
Dictionary<string, string> templateParams = new Dictionary<string, string>();
templateParams["messageParam"] = xmlNotification;
templateParams["titleParam"] = "testTitle";
templateParams["dataParam"] = "this is some data";
NotificationOutcome result = await
hub.SendTemplateNotificationAsync(templateParams, tagId);
config.Services.GetTraceWriter().Info(result.State.ToString());
客户端通知处理程序:
pushRegistration.on('notification', function (data) {
...
});
感谢Jeff Sanders提供以下文档
- 我们(Azure)方面的基础知识:
- 您需要的是自定义数据消息:
- 消息参数:
我可以将xml转换为对象。C#如何将字符串转换为javascript对象?另外,如何格式化Web服务的templateParams?
AzureDbSvc.client.push.register('gcm', handle, {
mytemplate: { body: { data: { message: "{$(messageParam)}", title: "{$(titleParam)}",
data: "{$(dataParam)}" } }, tags: arrTags }
pushRegistration.on('notification', function (data) {
...
});