React Native Push Notifications
React Native Local and Remote Notifications for iOS and Android
Installation
npm install react-native-push-notification
iOS Installation
The component uses PushNotificationIOS for the iOS part.
Please see: PushNotificationIOS
Android Installation
In your AndroidManifest.xml
..... .....
In android/settings.gradle
... include ':react-native-push-notification'project(':react-native-push-notification').projectDir = file('../node_modules/react-native-push-notification/RNPushNotificationAndroid')
In android/app/build.gradle
... dependencies { ... compile project(':react-native-push-notification')}
Register module (in MainActivity.java
)
// <--- Import
Usage
var PushNotification = ; PushNotification;
Handling Notifications
When any notification is opened or received the callback onNotification
is called passing an object with the notification data.
Notification object example:
foreground: false // BOOLEAN: If the notification was received in foreground or not message: 'My Notification Message' // STRING: The notification message data: {} // OBJECT: The push data
Local and Schedule Notifications
PushNotification.localNotification(details: Object)
PushNotification.localNotificationSchedule(details: Object)
(IOS ONLY)
EXAMPLE:
PushNotification; // IOS ONLYPushNotification;
Sending Notification Data From Server
Same parameters as PushNotification.localNotification()
iOS Only Methods
PushNotification.checkPermissions(callback: Function)
Check permissions
PushNotification.setApplicationIconBadgeNumber(number: number)
set badge number
PushNotification.getApplicationIconBadgeNumber(callback: Function)
get badge number
PushNotification.abandonPermissions()
Abandon permissions
TODO
- Add
PushNotification.localNotificationSchedule()
Android support