import { AppRegistry, StyleSheet, View, Text, Button } from 'react-native'; import React, {Component} from 'react'; import { Notifications } from '../lib/dist/index'; class NotificationsExampleApp extends Component { constructor() { super(); this.state = { notifications: [] }; this.registerNotificationEvents(); } registerNotificationEvents() { Notifications.events().registerNotificationReceived((notification, completion) => { this.setState({ notifications: [...this.state.notifications, notification.data.link] }); completion({alert: true, sound: false, badge: false}); }); Notifications.events().registerRemoteNotificationOpened((response, completion) => { this.setState({ notifications: [...this.state.notifications, `Notification Clicked: ${response.notification.data.link}`] }); completion(); }); } renderNotification(notification) { return {`${notification}`}; } requestPermissions() { Notifications.requestPermissions(); } setCategories() { const upvoteAction = { activationMode: 'background', title: String.fromCodePoint(0x1F44D), identifier: 'UPVOTE_ACTION' }; const replyAction = { activationMode: 'background', title: 'Reply', authenticationRequired: true, textInput: { buttonTitle: 'Reply now', placeholder: 'Insert message' }, identifier: 'REPLY_ACTION' }; const category = { identifier: 'SOME_CATEGORY', actions: [upvoteAction, replyAction] }; Notifications.setCategories([category]); } sendLocalNotification() { Notifications.localNotification({ body: 'Local notificiation!', title: 'Local Notification Title', sound: 'chime.aiff', category: 'SOME_CATEGORY', userInfo: { link: 'localNotificationLink' }, }); } removeAllDeliveredNotifications() { Notifications.removeAllDeliveredNotifications(); } async componentDidMount() { const initialNotification = await Notifications.getInitialNotification(); if (initialNotification) { this.setState({notifications: [initialNotification.data.link, ...this.state.notifications]}); } } componentWillUnmount() { } render() { const notifications = this.state.notifications.map((notification, idx) => ( {this.renderNotification(notification)} )); return (