1

我想在Xamarin Forms,windows phone 8.1 silverlight項目中做一個吐司通知顯示。在Windows Phone項目中,我有一個創建Toast通知的方法,但是,執行時沒有任何反應。沒有錯誤引發一切似乎正確執行,但沒有發生在手機上。Xamarin形式贏得手機silverlight 8.1吐司通知不起作用

我已經在模擬器和實際的手機上測試過它。到目前爲止,我在網上找到的所有東西都與我所擁有的相同(略有不同,但沒有任何區別)。

的方法中的代碼如下:

private void CreateNotification(string title, string message) 
{ 
    ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier(); 

    XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); 
    XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); 
    toastTextElements[0].AppendChild(toastXml.CreateTextNode(title)); 
    toastTextElements[1].AppendChild(toastXml.CreateTextNode(message)); 

    ToastNotification toast = new ToastNotification(toastXml); 
    toast.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(5); 

    toastNotifier.Show(toast); 
} 

任何幫助,將不勝感激。

在此先感謝!

回答

3

如果您正在使用Xamarin窗體有一個NuGet包:https://www.nuget.org/packages/Toasts.Forms.Plugin/

它不使用標準的Toast通知系統在Windows手機雖然,因爲它需要擴展超越它。

至於顯示Toast Notifications是否在Package.appxmanifest中設置Toast Capable爲Yes?

+0

非常感謝,我錯過了Toast Capable屬性! (我以前曾經找過這個屬性,但是看起來我完全錯過了,因爲你再次提到它,所以我決定再看一眼,然後驚訝它!) –