微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – Toast通知和地理栅栏Windows Phone 8.1

我的 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 @R_25_4045@ion 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.

谁知道如何解决这个问题?谢谢

解决方法

应用程序可能在后台抛出异常,但由于这是在后台,您无法看到它.我发现解决此类问题的唯一方法是向应用程序添加日志记录功能,以便您能够看到异常

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐