c# – Toast通知和地理栅栏Windows Phone 8.1
发布时间:2020-12-15 22:05:24 所属栏目:百科 来源:网络整理
导读:我的 Windows Phone 8.1应用程序遇到了一个奇怪的问题. 每当用户使用Geofence Quickstart: Setting up a geofence接近他感兴趣的点时,该应用程序将发送一个Toast通知 和BackgroundTask Quickstart: Listening for geofence events in the background 这是后
我的
Windows Phone 8.1应用程序遇到了一个奇怪的问题.
每当用户使用Geofence Quickstart: Setting up a geofence接近他感兴趣的点时,该应用程序将发送一个Toast通知 和BackgroundTask Quickstart: Listening for geofence events in the background 这是后台任务(示例) public void Run(IBackgroundTaskInstance taskInstance) { // Get the information of the geofence(s) that have been hit var reports = GeofenceMonitor.Current.ReadReports(); var report = reports.FirstOrDefault(r => (r.Geofence.Id == "id") && (r.NewState == GeofenceState.Entered)); if (report == null) return; // Create a toast notification to show a geofence has been hit var toastXmlContent = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); var txtNodes = toastXmlContent.GetElementsByTagName("text"); txtNodes[0].AppendChild(toastXmlContent.CreateTextNode("Geofence triggered toast!")); txtNodes[1].AppendChild(toastXmlContent.CreateTextNode(report.Geofence.Id)); var toast = new ToastNotification(toastXmlContent); var toastNotifier = ToastNotificationManager.CreateToastNotifier(); toastNotifier.Show(toast); } 现在的问题是,如果我从VS运行应用程序一切正常并且一旦进入特定区域就会触发Toast …如果我使用Windows Phone应用程序部署在设备上安装应用程序,该应用程序工作正常,同样使用模拟器.但是一旦上传到商店,我已经下载了应用程序和Toast,Geofence或BackgroundTask不再工作(我猜问题是这三个中的一个,但我不知道谁是罪魁祸首:s)..吐司通知不会触发.. 我还注意到我的应用程序未列在“通知操作”设置中,但在Package.appxmanifest中我设置了Toast Capable:YES. 谁知道如何解决这个问题?谢谢 解决方法
应用程序可能在后台抛出异常,但由于这是在后台,您无法看到它.我发现解决此类问题的唯一方法是向应用程序添加日志记录功能,以便您能够看到异常
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |