From ab2113c324540a90ff539ad40135d8f62377eea0 Mon Sep 17 00:00:00 2001 From: Tanguy Antoine Date: Fri, 22 Apr 2016 09:15:37 -0700 Subject: [PATCH] Update PushNotificationIOS documentation Summary:* add sample for localNotification listener Closes https://github.com/facebook/react-native/pull/7114 Differential Revision: D3212587 Pulled By: mkonicek fb-gh-sync-id: 1251a5563cf4254c4de491d45aafe8d1c24aeb0f fbshipit-source-id: 1251a5563cf4254c4de491d45aafe8d1c24aeb0f --- .../UIExplorer/PushNotificationIOSExample.js | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Examples/UIExplorer/PushNotificationIOSExample.js b/Examples/UIExplorer/PushNotificationIOSExample.js index 9dd4de4e1..8553f1f79 100644 --- a/Examples/UIExplorer/PushNotificationIOSExample.js +++ b/Examples/UIExplorer/PushNotificationIOSExample.js @@ -43,11 +43,17 @@ var Button = React.createClass({ class NotificationExample extends React.Component { componentWillMount() { + // Add listener for push notifications PushNotificationIOS.addEventListener('notification', this._onNotification); + // Add listener for local notifications + PushNotificationIOS.addEventListener('localNotification', this._onLocalNotification); } componentWillUnmount() { + // Remove listener for push notifications PushNotificationIOS.removeEventListener('notification', this._onNotification); + // Remove listener for local notifications + PushNotificationIOS.removeEventListener('localNotification', this._onLocalNotification); } render() { @@ -57,6 +63,11 @@ class NotificationExample extends React.Component { onPress={this._sendNotification} label="Send fake notification" /> + +