I'm trying to implementing local notification in IOS using this @react-native-community/push-notification-ios package.
I followed all the documentation properly. Still, LocalNotification is not working.
This is my environment config:
- react-native : 0.61.4
- @react-native-community/push-notification-ios --save : 1.0.5
I did the following things,
npm i @react-native-community/push-notification-ios --savecd ios && pod install- Updated
AppDelegate.mas per described here - Made build : react-native run-ios --device "iPhone X"
- Then calling function in my js like this,
import PushNotificationIOS from "@react-native-community/push-notification-ios";
.
.
.
componentDidMount(){
PushNotificationIOS.addEventListener('localNotification', this._onNotification);
PushNotificationIOS.requestPermissions();
PushNotificationIOS.presentLocalNotification({
alertBody: 'Test Notification'
});
}
_onNotification(notification) {
console.log(notification._alert);
}
.
.
.
- By the way, It requests for permissions when the first-time app opens & also I'm getting
console.logof notification but not getting any local notification.