mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
add local notification api schedule and present
Summary:
Add local notifications to the push library.
```
var PushNotificationIOS = React.PushNotificationIOS;
PushNotificationIOS.requestPermissions();
var notification = {
"fireDate": Date.now() + 10000,
"alertBody":"Whats up pumpkin"
};
PushNotificationIOS.scheduleLocalNotification(notification);
//lock screen or move away from app
```
Apple has another api for pushing immediately instead of scheduling, like when your background delegate has been called with some new data (bluetooth, location, etc)
```
var PushNotificationIOS = React.PushNotificationIOS;
PushNotificationIOS.requestPermissions();
var notification = {
"alertBody":"Whats up pumpkin"
};
PushNotificationIOS.presentLocalNotification(notification);
//lock screen or move away from app
```
Closed https://github.com/facebook/react-native/pull/843 looks related:
See https://developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/ for much more available in
Closes https://github.com/facebook/react-native/pull/1616
Github Author: Jacob Rosenthal <jakerosenthal@gmail.com>
This commit is contained in:
@@ -36,6 +36,31 @@ class PushNotificationIOS {
|
||||
_sound: string;
|
||||
_badgeCount: number;
|
||||
|
||||
/**
|
||||
* Schedules the localNotification for immediate presentation.
|
||||
*
|
||||
* details is an object containing:
|
||||
*
|
||||
* - `alertBody` : The message displayed in the notification alert.
|
||||
*
|
||||
*/
|
||||
static presentLocalNotification(details: Object) {
|
||||
RCTPushNotificationManager.presentLocalNotification(details);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules the localNotification for future presentation.
|
||||
*
|
||||
* details is an object containing:
|
||||
*
|
||||
* - `fireDate` : The date and time when the system should deliver the notification.
|
||||
* - `alertBody` : The message displayed in the notification alert.
|
||||
*
|
||||
*/
|
||||
static scheduleLocalNotification(details: Object) {
|
||||
RCTPushNotificationManager.scheduleLocalNotification(details);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the badge number for the app icon on the home screen
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user