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?

My App.Xaml.cs Function code is here.

OnLaunched Event:

 OneSignal.Init("32cdee4b-7838-4b6c-a024-ae25cecb2234", e);
 OneSignal.Init("32cdee4b-7838-4b6c-a024-ae25cecb2234", e, 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!

2 Answers 11

You first need to debug and check if it really receives the message in notificatonOpened method. It might be due to the message not being recived properly by it while in background.

upvote
  flag
when application is in background this method doesn't call, while when user click on received notification in notification bar then by coming in this method empty values display. – Arsal
upvote
  flag
Then it is the issue of values not being passed by library. One reason can be that your application gets terminated in background. Others need little bit of code verification – Rohit
up vote 2 down vote accepted

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.

upvote
  flag
yes You Are right. Sdk doesn't get message while user open notification from notification bar. but additional data and parameters have their value as it is. so I need to put my message in additional detail , where key and value parameters will return my result. – Arsal

Not the answer you're looking for? Browse other questions tagged or ask your own question.