4

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

And this is the Background task (example)

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);

}

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

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

4

1 回答 1

1

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

于 2014-10-01T17:00:15.650 回答