init() { PushNotification.configure({ onNotification(notification) { console.log( 'NOTIFICATION:', notification ); } }); }
componentDidMount(){ PushNotification.configure({ onNotification: (notification) => { const clicked = notification.userInteraction; if (clicked) { this.setState({ controllerLaunched: false}); } }, }); }
RNPushNotification.configure({ popInitialNotification: true, requestPermissions: true,
// Initialize local notifications. static init(callback: (Object) => void) { PushNotification.configure({ onNotification: (notification) => { log("Notification: " + notification); callback(notification); // Required for iOS. notification.finish(PushNotificationIOS.FetchResult.NoData); }, popInitialNotification: false, /** * (optional) default: true * - Specified if permissions (ios) and token (android and ios) will requested or not, * - if not, you must call PushNotificationsHandler.requestPermissions() later */ requestPermissions: false, }) }
componentDidMount() { // Configure Notifications. PushNotification.configure({ onNotification: function(notification) { console.log('RECEIVED NOTIFICATION'); }, requestPermissions: true, }) // Get our authToken. AsyncStorage.getItem('authToken', (err, authToken) => { if (err) console.log(err); // var authToken = JSON.parse(authToken); // If we have a token. if (authToken !== null){ this.setState({ authToken: authToken }); this.checkToken(authToken); this.handleSocket(authToken); // Else Login. } else { this.setState({ loading: false, authenticated: false }); } }); }
componentDidMount(){ PushNotification.configure({ onNotification: function(notification) { console.log( 'NOTIFICATION:', notification ); // process the notification // required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html) notification.finish(PushNotificationIOS.FetchResult.NoData); }, }); }
PushNotification.configure({ onRegister: function(token) { console.log('[LocalNotificationService] onRegister: ', token); }, onNotification: function(notification) { console.log( '[LocalNotificationService] onNotification: ', notification, ); if (!notification?.data) { return; } notification.userInteraction = true; onOpenNotification(notification.data); }, // ios only (optional): default: all - permission to register permissions: { alert: true, badge: true, sound: true, }, // popInitialNotification: true, // requestPermissions: true, });
PushNotification.configure({
componentDidMount() { let self = this; PushNotification.configure({
PushNotification.configure({
// Push notification related code PushNotification.configure({ onNotification: function(notification) { console.log( 'NOTIFICATION:', notification ); }, });
PushNotification.configure({ // (required) Called when a remote or local notification is opened or received onNotification: function(notification) { console.log('LOCAL NOTIFICATION ==>', notification); }, popInitialNotification: true, requestPermissions: true, });