Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

LocalNotification not working [IOS] - PushNotificationIOS

$
0
0

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,

  1. npm i @react-native-community/push-notification-ios --save
  2. cd ios && pod install
  3. Updated AppDelegate.m as per described here
  4. Made build : react-native run-ios --device "iPhone X"
  5. 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.log of notification but not getting any local notification.

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>