0

I used PushNotification library in react native. I was arrived to receive notification payload in foreground in my device with data object json .However in kill mode the object data received contain only title and soundName when i click on notification using (notification.userInteraction) .Can you help me to get data object which contain (refences key and startsation)and thinks :)

if (notification.userInteraction) {
}

if (notification.userInteraction) {
    // Handle notification click
    // alert('good');
    alert(JSON.stringify(notification));
    let notif=notification.data.aps.data;
    let id=notif.id;
    // alert("notificatin="+id);
}  

pubnub

{"pn_apns":{
    "aps":{
        "alert": {
            "body": "TEST",
              "title": "TEST1"
        },
        "sound": "beep.wav",

          "data": { "reference": "ND1004332", "startstation": "" }
    },
    "pn_push":[
        {
            "push_type":"alert",
            "auth_method":"token",
            "targets":[
                {
                    "environment":"development",
                    "topic":"com.oui.fr"
                }
            ],
            "version":"v2"
        }
    ]
}
}
Kirill Novikov
  • 2,576
  • 4
  • 20
  • 33
Nejib Afdhal
  • 51
  • 1
  • 9
  • My apologies, I can't understand the English. Are you saying that this payload is delivered to your app when the app is in foreground, however when the app is terminated by the user, the notification isn't delivered? Like You don't see anything at all? – mfaani Dec 21 '21 at 15:08
  • I sent notification ios via my device it works fine the data received in notification however in kill mode the data not found or not received – Nejib Afdhal Dec 21 '21 at 15:15
  • i used the notification.userInteraction by click to show notification json object – Nejib Afdhal Dec 21 '21 at 15:16
  • 1. Can you please show the payload? You removed it with your edit. 2. Show code for which delegate callback you're implementing. 3. Also dig deeper on `content-available` e.g. see [here](https://stackoverflow.com/questions/27777632/the-purpose-of-content-available-in-push-notification-json) and [here](https://stackoverflow.com/questions/19068762/will-ios-launch-my-app-into-the-background-if-it-was-force-quit-by-the-user). – mfaani Dec 21 '21 at 15:20
  • 4. See [here](https://stackoverflow.com/questions/39382852/didreceiveremotenotification-not-called-ios-10) and [here](https://stackoverflow.com/questions/42275060/what-is-difference-between-remote-notification-and-silent-notification-in-ios/42302369#42302369) for general tips – mfaani Dec 21 '21 at 15:20
  • i get just title and body and user intercation key in reveid notification – Nejib Afdhal Dec 21 '21 at 15:51
  • I don't know what user interaction means. Nor I know what you mean by "i get just title and body and user intercation key in reveid notification". Can you see my comments entirely. Also post the code for how you handle the notification – mfaani Dec 21 '21 at 16:26

1 Answers1

0

I solve it by change the structure of json in pubnub and adding content_available key.

 {"pn_apns":{
          "aps":{
            "alert": {
                "body": "TEST",
                "title": "TEST1"
            },
    "sound": "beep.wav
              },
",
             
    "data": { "reference": "ND1004332", "startstation": "" },
   "content_available" : "1",
          "pn_push":[
             {
                "push_type":"alert",
                "auth_method":"token",
                "targets":[
                   {
                      "environment":"development",
                      "topic":"com.oui.fr"
                   }
                ],
                "version":"v2"
             }
          ]
    
    }
          
    }  
Nejib Afdhal
  • 51
  • 1
  • 9