2
votes

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

2 Answers

2
votes

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.

0
votes

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.