Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push notifications if app is closed (React-Native)

I'm developing React-native app (iOS & Android).
Server connected through web-socket. Server sends notifications about some specific events. App suppose to notify user (using alerts). What if I need to notify user even if app is running in background or closed - how can i do that? Push notifications with this library will help in cases when app is in background, right? But it will not work if app is closed? So, how can i notify user if app is in background or closed?

like image 773
stkvtflw Avatar asked Jun 11 '16 18:06

stkvtflw


People also ask

Do push notifications work when app is closed?

Let's start with Android. The Android OS is designed to listen for push messages and upon receiving one, wake up the appropriate Android app to handle the push message, regardless of whether the app is closed or not.

How do I get notifications if an app is closed?

You use a Service. Services can run in the background even when the app is closed, and can start when the device boots up so even if the user has restarted their phone but hasn't opened the app, you can still send push notifications via the Service class. Use AlarmManager to start your service at the given time.

Can react Native send push notifications?

We can use the React Native Firebase library to integrate FCM on Android and the push-notification-ios library to integrate APNs on iOS. Also, the React Native Firebase library offers a way to receive push notifications on iOS through FCM.


1 Answers

The library you referenced will indeed allow you to notify users even if the app is closed as it utilised Push Notifications. These are delivered to your users' devices no matter the state of your app.

When a user opens a push notification they are taken to your app. This Push Notifications tutorial is a good introduction to the system.

like image 63
Tom Walters Avatar answered Oct 10 '22 06:10

Tom Walters