簡體   English   中英

Toast notification&Geofence Windows Phone 8.1

[英]Toast notification & Geofence Windows Phone 8.1

我的Windows Phone 8.1應用程序遇到了一個奇怪的問題。 每當用戶使用Geofence Quickstart接近他感興趣的點時,應用程序將發送一個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);

}

現在的問題是,如果我從VS運行應用程序一切正常並且一旦進入特定區域就會觸發Toast ...如果我使用Windows Phone應用程序部署在設備上安裝應用程序,該應用程序工作正常,同樣使用模擬器。 但是一旦上傳到商店,我已經下載了應用程序和Toast,Geofence或BackgroundTask不再工作(我猜問題是這三個中的一個,但我不知道誰是罪魁禍首:s)..吐司通知不會觸發..

我還注意到我的應用程序未列在“通知+操作”設置中,但在Package.appxmanifest中我設置了Toast Capable: YES

誰知道如何解決這個問題? 謝謝

應用程序可能在后台拋出異常,但由於這是在后台,您無法看到它。 我發現解決此類問題的唯一方法是向應用程序添加日志記錄功能,以便您能夠看到異常

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM