import { AppRegistry, StyleSheet, View, Text, Button } from 'react-native'; import React, {Component} from 'react'; import NotificationsIOS, { NotificationAction, NotificationCategory } from 'react-native-notifications'; let upvoteAction = new NotificationAction({ activationMode: 'background', title: String.fromCodePoint(0x1F44D), identifier: 'UPVOTE_ACTION' }, (action, completed) => { NotificationsIOS.log('ACTION RECEIVED'); NotificationsIOS.log(JSON.stringify(action)); completed(); }); let replyAction = new NotificationAction({ activationMode: 'background', title: 'Reply', behavior: 'textInput', authenticationRequired: true, textInput: { buttonTitle: 'Reply now', placeholder: 'Insert message' }, identifier: 'REPLY_ACTION' }, (action, completed) => { console.log('ACTION RECEIVED'); console.log(action); completed(); }); class NotificationsExampleApp extends Component { constructor() { super(); this.state = { notifications: [] }; NotificationsIOS.addEventListener('remoteNotificationsRegistered', this.onPushRegistered.bind(this)); NotificationsIOS.addEventListener('remoteNotificationsRegistrationFailed', this.onPushRegisteredFailed.bind(this)); NotificationsIOS.consumeBackgroundQueue(); NotificationsIOS.addEventListener('pushKitRegistered', this.onPushKitRegistered.bind(this)); NotificationsIOS.registerPushKit(); NotificationsIOS.addEventListener('notificationReceivedForeground', this.onNotificationReceivedForeground.bind(this)); NotificationsIOS.addEventListener('notificationOpened', this.onNotificationOpened.bind(this)); } onPushRegistered(deviceToken) { console.log('Device Token Received: ' + deviceToken); } onPushRegisteredFailed(error) { console.log('Remote notifiction registration failed: ' + error); } onPushKitRegistered(deviceToken) { console.log('PushKit Token Received: ' + deviceToken); } onNotificationReceivedForeground(notification, completion) { console.log('Notification Received Foreground: ' + JSON.stringify(notification)); this.setState({ notifications: [...this.state.notifications, notification] }); completion({}); } onNotificationOpened(notification) { console.log('Notification Opened: ' + JSON.stringify(notification)); } renderNotification(notification) { return {`${''} | ${JSON.stringify(notification)}`}; } render() { const notifications = this.state.notifications.map((notification, idx) => ( {this.renderNotification(notification)} )); return (