問題描述
我正在為 Windows Phone 8.1 開發 One Signal Push Notifications.通知工作正常.但是當我點擊通知時,消息顯示空值.當應用程序打開時,則在事件中顯示消息.如何獲取通知文本以保存在我的通知屏幕中?
I'm working on One Signal Push Notifications for windows phone 8.1. Notification works fine. but when I click on notification then the message display empty value. While when application is ON then message display in event. how can I get the notification text to save in my notification screen?
我的 App.Xaml.cs 函數代碼在這里.
My App.Xaml.cs Function code is here.
啟動事件:
OneSignal.Init("32cdee4b-7838-4b6c-a024-ae25cecb2234", e);
OneSignal.Init("32cdee4b-7838-4b6c-a024-ae25cecb2234", e, notificationOpened);
這是notificationOpened函數代碼:
Here is notificationOpened Function Code:
private async void notificationOpened(string message, IDictionary<string, string> additionalData, bool isActive)
{
if (message != null && message != "")
{
DatabaseHelperClass Db_Helper = new DatabaseHelperClass();//Creating object for DatabaseHelperClass.cs from ViewModel/DatabaseHelperClass.cs
try
{
Db_Helper.Insert(new MessagesClass(message));
}
catch
{
MessageDialog messageDialog = new MessageDialog("There is an error while saving this details. Please try again later!");//Text should not be empty
await messageDialog.ShowAsync();
}
}
else
{
//Here I have check for empty value
settingsClass.SaveSetting("NotiClick", "MoveToMeldingen");
}
當應用程序處于活動狀態時,我會收到消息,但是當應用程序處于后臺并且通知在通知托盤中收到時,單擊此按鈕我會收到空??消息字符串.請幫助我擺脫這個問題.謝謝!
When application is on active state then I gets the message but when application is in background and notification receives in notification tray then y clicking on this I gets empty message string. Please help me to get rid of this issue. Thank you!
推薦答案
這是 Windows Phone 8.1 通知的一個限制,其中消息正文未傳遞到應用程序.問題是傳遞給 OnLaunched
的 LaunchActivatedEventArgs
不包含此值,因此 OneSignal SDK 無法獲取此值.您可以設置一個斷點或打印出 e.Arguments
以查看它 WP8.1 沒有通過它.
It is a limitation of Windows Phone 8.1 notifications where the message body isn't passed to the app. The issue is that LaunchActivatedEventArgs
passed to OnLaunched
doesn't contain this so the OneSignal SDK can't get this value. You can set a break point or print out e.Arguments
to see that it WP8.1 isn't passing this.
不過,您可以通過將消息添加到附加數據"以及數據參數仍會傳遞給您的應用來解決此問題.
You can work around this however by adding your message to Additional Data as well as data parameters are still passed to your app.
這篇關于OneSignal 推送通知 ClickEvent 顯示空值 Windows phone 8.1 C#的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!