wix / react-native-notifications

React Native Notifications
MIT License
3.23k stars 763 forks source link

local notifications not showing #915

Closed ysnbyzli closed 1 year ago

ysnbyzli commented 1 year ago

Hi,

import {SafeAreaView, Button} from 'react-native';
import React from 'react';
import {Notifications} from 'react-native-notifications';
const App = () => {
  const handleNotifications = () => {
    const notification = Notifications.postLocalNotification({
      body: 'Local notification!',
      title: 'Local Notification Title',
      userInfo: {},
    });
  };
  return (
    <SafeAreaView>
      <Button title="Touch me" onPress={handleNotifications} />
    </SafeAreaView>
  );
};

I want to show a local notification with this code, but nothing happens

ajaybushel commented 1 year ago

I don't think you need to create a variable. Simply do:

const handleNotifications = () => {
  Notifications.postLocalNotification({
    body: 'Local notification!',
    title: 'Local Notification Title',
    userInfo: {},
  });
};

Just tried the above code and it works.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] commented 1 year ago

The issue has been closed for inactivity.