- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我一直在尝试在我的 Windows 和 Windows Phone 8.1 应用程序上为 Raw Push Notifications 实现 BackgroundTask,但它似乎不起作用。我已经成功地让基于 toast 的推送通知正常工作,但据我所知,Raw 通知会静默将数据推送到应用程序,并且由应用程序来显示 toast 通知或更新应用程序的磁贴。
我查看了 BackgroundTask 示例并完全遵循它但没有任何效果 (https://code.msdn.microsoft.com/windowsapps/Background-Task-Sample-9209ade9)。
这是我采取的步骤
IBackgroundTask
及其 Run
方法创建了一个方法来创建 toast 通知
private void SendNotification(字符串文本) { XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
XmlNodeList elements = toastXml.GetElementsByTagName("text");
foreach (IXmlNode node in elements)
{
node.InnerText = text;
}
ToastNotification notification = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(notification);
}
向 Run 方法添加代码
BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();
RawNotification notification = (RawNotification)taskInstance.TriggerDetails;
string content = notification.Content;
// ...
SendNotification("test");
// ...
_deferral.Complete();
将我的应用 list 更新为 Toast Capable = YES
和 Lock Screen Notifications = Badge
为后台任务添加了声明,Supported Task Type = Push Notification
和 Entry Point = NotificationServer.RawTask
添加代码以注册后台任务
public static BackgroundTaskRegistration RegisterBackgroundTask(string taskEntryPoint, 字符串任务名称, IBackgroundTrigger 触发器, IBackgroundCondition条件) { // //检查此后台任务的现有注册。 //
foreach (var cur in BackgroundTaskRegistration.AllTasks)
{
if (cur.Value.Name == taskName)
{
//
// The task is already registered.
//
return (BackgroundTaskRegistration)(cur.Value);
}
}
//
// Register the background task.
//
var builder = new BackgroundTaskBuilder();
builder.Name = taskName;
builder.TaskEntryPoint = taskEntryPoint;
builder.SetTrigger(trigger);
if (condition != null)
{
builder.AddCondition(condition);
}
BackgroundTaskRegistration task = builder.Register();
return task;
}
并用
执行它var reg = RegisterBackgroundTask("NotificationServer.RawTask", "RawNotifications", new PushNotificationTrigger(), null);
这里有什么我遗漏的吗,我的应用程序似乎没有响应推送通知事件。我已确保我的应用程序与商店中的应用程序相关联,并且使用正确的客户端密码和应用程序 ID 发送推送。
最佳答案
有四种类型的推送通知:
所有 Windows 运行时应用程序都可以在前台使用前三个推送通知。只有锁屏应用可以接收来自 WNS 的原始推送通知。因此,您必须将您的应用设为锁屏应用。
可以关注this topic这样做。
关于c# - 在 WNS 中使用原始推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27642646/
我正在尝试根据以下 Microsoft 教程设置 Windows (WNS) 通知:Send notifications to Universal Windows Platform apps usin
我一直在尝试在我的 Windows 和 Windows Phone 8.1 应用程序上为 Raw Push Notifications 实现 BackgroundTask,但它似乎不起作用。我已经成功
它是 Windows 运行时、Windows Phone 目标项目。 我正在使用 Azure 和 Azure 通知中心。所以我的问题是有人如何导航到某个特定页面并发送 id 等参数。 这是我的 toa
更新通知中心时出错: {"error":{"message":"SubCode=40000. Failed to validate credentials with WNS. The remote s
我记得听说过的是,使用 WNS,您可以为发送的通知指定特殊的声音,就像 Android 所做的那样。 . 我浏览过不同的网站msdn , urban和 microsoft examples ,我找到的
更新通知中心时出错: {"error":{"message":"SubCode=40000. Failed to validate credentials with WNS. The remote s
我记得听说过的是,使用 WNS,您可以为发送的通知指定特殊的声音,就像 Android 所做的那样。 . 我浏览过不同的网站msdn , urban和 microsoft examples ,我找到的
我有一个从 WNS 接收通知的 C#/UWP 应用程序,我可以使用 Azure 通知中心测试页面向它发送原始通知。唯一的问题是我无法在集线器上注册设备以在发送模板通知时接收原始通知。这是基本代码: P
我正在创建一个应用程序,它不断使用推送通知作为用户之间的通信方式(各种消息传递)。整个考验似乎让我有点抓狂,所以这里有几个我找不到答案的问题。 我发现提到在 MPNS 中,未经身份验证的 Web 服务
我正在通过 WNS 和 WINJS (windows Phone 8.1) 处理推送通知。我关注了这篇文章https://msdn.microsoft.com/en-us/library/window
我正在尝试为 Windows Server 2013 设置 Windows 推送通知服务 (WNS)。但我似乎无法在网上找到任何与此相关的文档,因为其中大部分只是对客户端进行了更多解释。 非常感谢任何
Azure 通知中心显示,在 13k 个 WNS Toast 通知广播中,仅 5k 条消息成功,8k 条消息出现“WNS channel 已断开”错误。什么会导致如此大的错误?我可以检查什么,为什么会
我有一个包含移动客户端和 Windows 8 客户端的应用程序。我想在两个应用程序之间实现推送通知服务。 我发现 windows 8 使用 WNS (windows Notification Serv
WNS 是否可用于 Windows Phone 8 设备。如果是,我在哪里可以找到一些好的文档来使用它。 我正要使用 MPNS 但 here它说微软正在从 Windows Phone 8.1 中淘汰
我有一个在 Windows Phone 8.1 设备上运行的 Windows Phone 应用程序,我正在使用 Windows Push Notification Services (WNS) 向设备
在 here 的帮助下,我们刚刚将现有的 Windows Phone 8 Silverlight 应用程序升级到 Windows Phone 8.1 Silverlight 项目。基本上我们想使用 W
我有 Windows Phone 8.1 silverlight 应用程序,我想在其中使用新框架 WNS 接收通知。 我在package.appxmanifest中有:并将其添加到移动服务中心。 为此
我有一个非常简单的 Cordova 应用程序,带有推送通知。我正在使用 VS2015 Update 1 和最新的 Cordova 工具集(Update 7)以及正确设置的 Azure 应用服务。当我通
我是一名优秀的程序员,十分优秀!