10

I am trying to create a local notification in android using react-native. My application is completely local, so I don't want to use GCM or FCM. I saw this question where it is done using java. Is there wrapper or a library in React Native to achieve the same?

I also saw PushNotificationIOS API, will it work with Android?

Pavel Chuchuva
  • 22,633
  • 10
  • 99
  • 115
Manu Viswam
  • 1,606
  • 2
  • 18
  • 33

4 Answers4

8

Yes, react-native-push-notifications. It does local notifications too on both iOS and Android.

https://github.com/zo0r/react-native-push-notification

pomo
  • 2,251
  • 1
  • 21
  • 34
  • 29
    I don't want GCM features as I'm not gonna use it. Is there a simple library which can achieve only local notifications? – Manu Viswam Sep 05 '16 at 16:52
  • You can use react-native-push-notification library to send local notifications on both iOS and Android. – pomo Sep 07 '16 at 07:40
  • 1
    This library sucks - see issue below with no solution https://stackoverflow.com/questions/63144729/react-native-push-notification-android-notification-keeps-repeating-and-wont – james murphy Aug 02 '20 at 21:26
3

Wix has the best plugin for notifications.

Includes Local Notifications AND Push (Android & iOS)

https://github.com/wix/react-native-notifications

If you don't want to use push, you can skip the configuration and just install & link to start using

npm install --save react-native-notifications
react-native link react-native-notifications

Take a look at the install guide: https://github.com/wix/react-native-notifications/blob/master/docs/installation.md

Example of use

let localNotification = NotificationsIOS.localNotification({
    body: "Local notificiation!",
    title: "Local Notification Title",
    sound: "chime.aiff",
    silent: false,
    category: "SOME_CATEGORY",
    userInfo: { }
});

NotificationsAndroid.localNotification({
    title: "Local notification",
    body: "This notification was generated by the app!",
    extra: "data"
});

You can find more information on local notifications at https://wix.github.io/react-native-notifications/docs/localNotifications

Also, the notifications layout can be fully customized on Android

muZk
  • 2,908
  • 1
  • 21
  • 22
Guilherme Ferreira
  • 2,209
  • 21
  • 23
  • 2
    Wix plugin doesn't work for android. As soon as I added wix react-native-notifications android app crashes though iOS works properly – Payel Dutta May 12 '20 at 19:56
  • The link to the local notifications doesn't work and those three parameters to create the Android notifications are not enough. – Roc Boronat May 27 '20 at 16:07
  • Here is the link https://wix.github.io/react-native-notifications/docs/localNotifications – muZk Jun 16 '20 at 16:27
  • Anyone got the wix's react-native-notifications plugin work for Local Notifications on Android? – ilight Apr 04 '22 at 06:42
  • any updates on this? android docs are very limited, how to customize local notification? how to add image? setup actions?... – mohas Oct 31 '22 at 15:56
1

You can use https://github.com/zo0r/react-native-push-notification to handle local notification. You can use it with out GCM dependencies. Read through Usage section GCM and scheduled notifications are optional. I am using this with Jobscheduler to avoid FCM dependencies.

Ajitsen
  • 338
  • 3
  • 7
  • I have a question, I'm developing two apps first of the user app and second to providers, in user app, I made some function to send order and saved into real-time database firebase t and in the second app I just retrieve the data from DB with a listener to get the new order as a real-time without refreshing the app, SO I want to when I send an order from user app to firebase I want to display a notify in the second app? How to handle these – DevAS May 14 '19 at 05:25
  • the major problem is the installation, there is not much clear docs, if you don't want to use the firebase. – Aman Deep Jul 07 '22 at 14:08
1

Consider Notifee library.

Notifee enables developers to rapidly build rich notifications with a simple API interface, whilst taking care of complex problems such as scheduling, background tasks, device API compatibility & more.

Pavel Chuchuva
  • 22,633
  • 10
  • 99
  • 115