C# 吐司通知及;Geofence Windows Phone 8.1

C# 吐司通知及;Geofence Windows Phone 8.1,c#,windows-phone-8,toast,windows-phone-8.1,winrt-component,C#,Windows Phone 8,Toast,Windows Phone 8.1,Winrt Component,我的Windows Phone 8.1应用程序遇到了一个奇怪的问题。 每当用户使用Geofence靠近他感兴趣的地点时,应用程序都会发送一个toast通知 背景任务 这是后台任务(示例) 现在的问题是,如果我从VS运行应用程序,所有工作正常,并且一旦进入特定区域就会触发Toast。。。如果我使用Windows Phone应用程序部署在设备上安装该应用程序,则该应用程序运行良好,使用Emulator也是如此。但是,一旦上传到商店,我就下载了应用程序,Toast、Geofence或Backgroun

我的Windows Phone 8.1应用程序遇到了一个奇怪的问题。 每当用户使用Geofence靠近他感兴趣的地点时,应用程序都会发送一个toast通知 背景任务

这是后台任务(示例)

现在的问题是,如果我从VS运行应用程序,所有工作正常,并且一旦进入特定区域就会触发Toast。。。如果我使用Windows Phone应用程序部署在设备上安装该应用程序,则该应用程序运行良好,使用Emulator也是如此。但是,一旦上传到商店,我就下载了应用程序,Toast、Geofence或BackgroundTask就不再起作用了(我想问题是这三者之一,但我不知道谁是罪魁祸首:s)。。。toast通知不会触发

我还注意到,我的应用程序没有列在“通知+操作”设置中,而是列在Package.appxmanifest中,我已将Toast设置为支持:


有人知道怎么解决这个问题吗?谢谢

应用程序可能会在后台抛出异常,但由于这是在后台,因此您无法看到它。我发现解决这类问题的唯一方法是在应用程序中添加日志功能,这样你就可以看到异常

显然,一旦发布,就不会注册BackgroundTask。但同样的代码可以完美地使用模拟器和设备调试解决方案。我希望这有助于找到解决办法。
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);

}