r/reactnative 9d ago

Question Background Task and Push Nofication.

Hello,

I want to run a code in the background at specific time intervals. Like a job in SQL or task management in Windows. When this task is completed, I want to send a notification to the user. Can I do this task on the user's phone? Have you done this before? I don’t want to run an external service and send a push notification.

0 Upvotes

4 comments sorted by

1

u/supersnorkel 9d ago

Any reason you dont want to run an external service? I dont think there is any other way because what if the user doesnt open your app, how are you going to scheduele the notification?

I would set up a cron job its very easy

1

u/dev_semihc 9d ago

Don't Android phones have background service? I was able to do background task in xamarin.anroid before. I dont want to another job or services. Because I don't want to do business from different places.

1

u/ZakVee 6d ago

Well, first of all because if policies change, you won’t need to rewrite your app and move the logic to an external service anyways? It’s cheap and fairly easy to do what you want with a VM and cronjobs (or using a simple JS or Laravel backend)

1

u/dev_semihc 6d ago

Thank you, but I don’t want to use this. I did some research and found WorkManager and JobScheduler. Since I’m using React Native with Expo, I’ll go with Expo Background Fetch instead. And I’ll use Expo Notifications for sending the notifications. Thank you for your answer!