handleActionsPush() { PushNotification.localNotification({ title: 'Deseja mudar de view?', message: 'Escolha sim para acessar a home', actions: '["Yes", "No"]', }); }
socket.on('inc_notif', (data) => { PushNotification.localNotification({ message: 'It is your turn to buy: \n' + data.quantity + ' of ' + data.resource }); PushNotification.setApplicationIconBadgeNumber(1) Alert.alert('It is your turn to buy: \n' + data.quantity + ' of ' + data.resource); socket.emit('received_notif', data); })
init() { PushNotification.configure({ onNotification(notification) { console.log( 'NOTIFICATION:', notification ); } }); }
_sendScheduledLocalNotificationUsingLib() { PushNotification.localNotificationSchedule({ message: "My Scheduled Notification Message", // (required) date: new Date(Date.now() + (5 * 1000)) // in 60 secs }); }
constructor(props) { super(props); const { navigate } = this.props.navigation; PushNotificationAndroid.registerNotificationActions(['Yes', 'No']); DeviceEventEmitter.addListener('notificationActionReceived', function (action) { const info = JSON.parse(action.dataJSON); if (info.action == 'Yes') { navigate('HelloWorld'); } }); }
static scheduleReminderNotifications(isoTime: string) { // First, clear existing notifications--can only have one reminder // scheduled. this.clearReminderNotifications(); // Schedule the notification. PushNotification.localNotificationSchedule({ message: Localized('Notifications.message'), date: parseISODateString(isoTime), repeatType: Platform.OS === 'ios' ? 'day' : 'daily', }); }
static clearReminderNotifications() { PushNotification.cancelAllLocalNotifications(); }
export function clearNotifications() { RNPushNotification.cancelLocalNotifications({ id: NOTIFICATION_ID }); }
componentDidMount(){ PushNotification.configure({ onNotification: (notification) => { const clicked = notification.userInteraction; if (clicked) { this.setState({ controllerLaunched: false}); } }, }); }
schedule(opts) { PushNotification.localNotificationSchedule(opts); }
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); }, }); }
handlePush() { PushNotification.localNotification({ title: 'my title', message: 'lorem ipsum dolor' }); }
// 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, });
export function deleteReminder(id) { return PushNotification.cancelLocalNotifications({id}); }