问题描述
我正在为Windows Phone 8.1处理一个信号推送通知".通知工作正常.但是,当我单击通知时,消息将显示空值.当应用程序打开时,将在事件中显示消息.如何获取通知文本以保存在我的通知屏幕中?
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.
OnLaunched事件:
OnLaunched Event:
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#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!