烤面包通知和地理围栏Windows Phone 8.1 [英] Toast notification & Geofence Windows Phone 8.1

查看:133
本文介绍了烤面包通知和地理围栏Windows Phone 8.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Windows Phone 8.1应用程序面临一个奇怪的问题. 每次用户使用Geofence 快速入门:设置地理围栏 和BackgroundTask 快速入门:在后台监听地理围栏事件

I'm facing a strange problem with my Windows Phone 8.1 App. The App will send a toast notification every time the user is near a Point of his interest using Geofence Quickstart: Setting up a geofence and 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). .吐司通知不会触发..

Now the problem is that if I run the App from VS all works fine and the Toast is triggered once entered the specific Area... if I install the App on the device using the Windows Phone Application Deployment the app works fine, and same using the Emulator. But once Uploaded to the store, I've downloaded the App and the Toast, Geofence or BackgroundTask doesn't work anymore (I guess the problem is one of those three but I don't know who is the culprit :s)... the toast notification just won't trigger..

我还注意到,我的应用未在通知+操作"设置中列出,但在Package.appxmanifest中已设置为Toast Capable:.

I've also noticed that my App isn't listed in the "Notification+Action" settings, but in the the Package.appxmanifest I've set Toast Capable: YES.

有人知道如何解决这个问题吗?谢谢

Anyone knows how to solve this? Thanks

推荐答案

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

The application may be throwing an exception in the background but since this is in the background you can not see it. The only way I have found to resolve this type of issue is adding logging functionality to the App so you will be able to see the exception

这篇关于烤面包通知和地理围栏Windows Phone 8.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆