系统相关
首页 > 系统相关> > c# – Toast通知和地理栅栏Windows Phone 8.1

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 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.

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

解决方法:

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

标签:c,toast,windows-phone-8,windows-phone-8-1,winrt-component
来源: https://codeday.me/bug/20190708/1404490.html