I am trying to use this lib. with the Salesforce SDK app in IOS device
When I am trying to create Local notification at that App is showing Push notification but its configure method 'notification' is not getting called
Also on the launching of the application, When I ran 'onRegister ' it also not getting called to becasue of this I am unable get device token ID
having same issue in android
I am also having the same issue
I have the same issue on iOS. As suggested elsewhere I added an event listener for registrationError to get more information.
PushNotificationIOS.addEventListener('registrationError', (e) => console.log(error);
In the iOS simulator it logs a message that onRegister is not supported in the simulator. That was expected.
I am bugsnag to keep track of my errors in production but strange enough the event listener is not triggered in a testflight build. I am sure onRegister is not called in production since I store the token in the component's state and print it in the render function of App.js.
RN version is on 0.57.8
I have got it working on iOS!
Not 100% sure what fixed it though. I think that the trick was to move PushNotifictions.configure({) from componentDidMount to the constructor! I can't give a logic explanation why it works now.
Another important thing: if your onRegister function is NOT an ES6 array function you can not access the this context of a class component. So in other words, if you try to call this.setState or this.props.someReduxActionCreator it will not work.
class PushHandler extends React.Component {
constructor(props) {
super(props);
PushNotification.configure({
onRegister: token => {
// Calling the redux action creator that was mapped to the props via mapDispatchToProps
props.updateUserKey({ deviceToken: token });
// Or store it in AsyncStorage, or in my case RNSecureStorage.
RNSecureStorage.set('deviceToken', JSON.stringify(token), {
accessible: ACCESSIBLE.WHEN_UNLOCKED
});
},
onNotification: notification => {
Alert.alert(JSON.stringify(notification));
},
...
@timkuilman does this work for iOS simulator?
I had the same experience, my solution was uninstall the app and install it again, maybe it is something cached based on a different lib
I need help, I still can't get the device token, there are no more errors at all, the onRegister is not returning the token at all. I am using external device IOS.
Most helpful comment
I need help, I still can't get the device token, there are no more errors at all, the onRegister is not returning the token at all. I am using external device IOS.