我正在为 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模板网!