0

I am trying to configure my app to redirect according to the payload data, if post_id or page_id or no payload different redirects for these three payloads.

Here is what I am getting in push details:

Push message response

In above image you can see there is a payload data post_id with some value it can be page_id for sometime, so I need to check if the key is post_id or page_id in the payload data and if yes then if the value is null or not.

I tried:

pushPayload.indexOf('post_id') !== -1 
parseInt(pushPayload['post_id']) > 0
msg.payload.hasOwnProperty('post_id')

but nothing worked.

Please help.

Sanny Srivastava
  • 1,067
  • 1
  • 12
  • 23
  • 1
    Possible duplicate of [Check if a key exists inside a json object](http://stackoverflow.com/questions/20804163/check-if-a-key-exists-inside-a-json-object) – Suraj Rao Apr 19 '17 at 09:57
  • I already tried the solution but that shows an error....and in that question keys were static and for me it can be different like post_id or page_id – Sanny Srivastava Apr 19 '17 at 09:59
  • is this the return of a fcm push? Can you post the entire JSON it's returning? – Gabriel Barreto Apr 19 '17 at 14:10
  • yeah the above screen shot is PUSH response excluding (I received awesome push: ), sorry I can not copy paste it as text I am showing it in alert box. – Sanny Srivastava Apr 20 '17 at 05:58

0 Answers0