我的Windows Phone 8.1應用程序遇到了一個奇怪的問題。 該應用程序會在每次用戶接近使用地理圍欄Quickstart: Setting up a geofence 和BackgroundTask Quickstart: Listening for geofence events in the backgroundToast notification&Geofence Windows Phone 8.1
他的興趣的一個時間點發送Toast通知這是後臺任務(例如)
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應用程序部署在設備上安裝應用程序,該應用程序工作正常,並使用模擬器相同。但一旦上傳到商店,我已經下載了應用程序和吐司,Geofence或BackgroundTask不再工作了(我猜這個問題是其中的一個,但我不知道誰是罪魁禍首)。 。吐司通知只是不會觸發..
我也注意到我的應用程序沒有列在「通知+行動」設置,但在Package.appxmanifest我已經設置Toast Capable: 是。
任何人都知道如何解決這個問題?謝謝
顯然,似乎一旦發佈,就不會註冊BackgroundTastk。但是相同的代碼完美地調試了Emulator和Device的解決方案。 我希望這可以幫助找到解決方案。 – Valerio