react-native-push-notification: PushNotification.configure doesn't work
Hello,
Here is how I followed the reading is when I run the application I can not display the token because it does not fit in the PushNotification.configure present componentDidMount(). Can anybody help me? Thank you
import PushNotification from 'react-native-push-notification';
type Props ={};
export default class App extends Component<Props>{
componentDidMount(){
console.log('Did Mount');
PushNotification.configure({
onRegister:function(token) {
console.log('TOKEN: ', token);
},
onNotification:function(notification) {
console.log('NOTIFICATION: ',notification);
},
senderID: "826032976309",
popInitialNotification: true,
requestPermissions: true,
});
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 27 (3 by maintainers)
Hi!! I could solve it, placing PushNotification.configure() outside the component.
Example:
I was experiencing the same issue when sending local notifications to a simulator, the onNotificaiton is not fired. Works fine for real device.
Hi @aakrandan The README explain how to handle this, read the Usage Part,
requestPermissions. Regards