React-native-push-notification: Can we get PushNotificationIOS.getInitialNotification() for Android ?

Created on 3 May 2020  路  4Comments  路  Source: zo0r/react-native-push-notification

Can we get PushNotificationIOS.getInitialNotification() for Android ?

async componentDidMount (){
  if(Platform.OS === "ios"){
 const res = await PushNotificationIOS.getInitialNotification()
  console.log("ressss", res)
  }else{
 // this always breaks and returns undefined
  const res2 = await PushNotification.popInitialNotification();
  console.log("ressss22", res2)
  }
}

Most helpful comment

Hi @allindeveloper
Great news ! 馃槂

All 4 comments

Hi @allindeveloper
Can you test with a callback instead of a promise ?

@Dallas62 I tried this

PushNotification.popInitialNotification((callback)=>{
        console.log("ress from android ---2 ", callback.userInfo)
      })

And it works perfectly, i was able to retrieve my data
Thank You

@Dallas62
And i think it would solve the initial issue i raised here...
https://github.com/zo0r/react-native-push-notification/issues/1390
I figured i could do a logic on my splash screen to check if there is any initial notification data and reroute to my desired page.
I hope this helps someone!

Hi @allindeveloper
Great news ! 馃槂

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sungjinoh picture sungjinoh  路  3Comments

nidzovito picture nidzovito  路  3Comments

cidevant picture cidevant  路  3Comments

atteia picture atteia  路  4Comments

Benzer1406 picture Benzer1406  路  3Comments