react native - custom expo notifications schedule - react-native

I am working on a react-native based mobile app using expo.
in the app the user can set schedules for medication reminders, for that I am using expo-notifications to show those reminders.
expo-notifications provides some functions to schedule notifications, but as I found in the docs it does not provide scheduling options that I need, like every Sunday at 09:00am, or every 2 days at 05:00pm, daily at 08:30pm, and so on...
How can I achieve such scheduling?

expo-notifications author here! 👋
It depends on your use case, but I would suggest either:
use push notifications sent from your backend, where you can design any schedule you like (disadvantage would be that an offline device wouldn't receive the notification and that you'd have to write and maintain that backend)
try to work around the limitations
every Sunday at X soon will be achievable with WeeklyTrigger
every 2 days is tricky, maybe an interval trigger with some offset (not possible right now, but I'll happily review a pull request if you submit one)
daily at X is already supported with DailyTrigger
submit a pull request adding missing trigger types or adding features to existing ones.

Related

React-Native Background Tasks - repeat less then 15 Minutes?

The following question: In React-Native via the library react-native-background-fetch it is possible to execute a task in the background. For example to send a push notification. I looked at the following example in the course: https://medium.com/#alihaghani/background-tasks-and-local-push-notifications-with-react-native-d63fc7fff9b
Now in the documentation of "react-native-background-fetch" it is written that it is not possible to run a task under 15 minutes interval. Does anyone know how I can still run a task for example every minute or every 2 minutes?
If not, does anyone have a solution for the following problem:
(minimal example) I have an app that searches for Bluetooth connections in your area. When a signal is found, then show a push notification. Every minute it searches for a signal. This should happen in the background of course. For this it should be checked under 15 minutes.
Is this somehow possible with react-native?
I have already built an app that displays push notifications. I have implemented this with Firebase. In my opinion, Firebase will not be able to help me here, because the push notification is only sent when a certain logic applies, right?
Thanks to anyone who can give me some thought or even a solution to the problem

How to create real time tracking apps like Uber using react native?

I am working with real time tracking application using react-native.
And want the accuracy Uber and Swiggy and other tracking application do.
I am using react-native-geolocation-service, but not getting accuracy like Uber.
I just want to know how Uber track realtime? Does they request to server every single second?
Because there position is moving continuously, which is not possible in my app. I am saving coordinates after every 15 seconds.
Please suggest what can I use for making accurate path?
And what does Uber and other tacking apps used for tracking? And how they get realtime data for every single second?
For getting real time location you can use paid services like https://www.navixy.com/. I have used this service year ago and they are providin lot of functionalities track Android device with their API's.
Try Firebase Realtime database or cloud firestore. It works like realtime data update.
Store lat long on firestore/database whenever there is change in position and within a second you will be able to get those data on other end.
It is having nice performance when it comes to real time data update. I have used it with one of the native application before a year.
For react native, you can use Geolocation api which is having watchposition method. It will be invoked whenever there is location change.

Securely set date that user can't manipulate react-native

Building a simple application which restricts usage based on the date. For example, you can only view a page 3 times per day.
However, if I use the device time, users can change their time and then view these pages again.
Is there another best practice method of doing so? Trying to avoid a call to the server. Using react-native. Thanks
Best practice is only use server time.
you can use following lib
https://github.com/artem-russkikh/react-native-clock-sync
This is kinda tricky without hitting the server.
into
Let's assume that the first time they open your app the user date is correct. (I really don't know any other way checking that in an offline way)
That moment we need to save the current timestamp to the localstorage (called AsyncStorafe in RN).
solution
The only way you can really be sure that the timestamp is correct is keep a task that counts every seconds/minute/hours, whatever is logical in your situation.
issue
Doing this in react native won't get you that far, but we are able to make a Java background service for example that we start as soon as the app closes. Here you should keep up with the time and save this when the app launches to a place where it's also accessible from react native (not sure if AsyncStorage is).
Info
Here you can find some information about bavkground tasks in RN: https://hackernoon.com/easy-os-background-tasks-in-react-native-bc4476c48b8a?source=linkShare-cdf0b7d5ccb4-1538965801
The most secure amd easy way of time cheat prevention is by hitting the server vut if that's not a possibility that this may be a interesting way to still check it. Good luck!

Daily scheduled notifications

I need a bit of guidance, so for my application i'm looking at using local notifications to send a notification every morning at 7 o'clock.
The issue i'm having is how can i make the content for the local notification dynamic mainly the body and the attached image? As it will vary for the user on a daily basis.
What would be the best way to go about this since you can't edit future notifications.
Here's a little lesson about notifications. First, what is a notification? It's basically an alert presented on your behalf by the system. Second, there are two kinds of notification: local and remote.
Let's imagine, then, an app that aims to present a notification to the user every morning at 7 AM saying what the current temperature is outside. (Assume for purposes of the example that we have a way of learning this information.)
A moment's thought will reveal that this cannot be done with local notifications. We cannot know the current temperature at 7 AM until 7 AM (or close to it) and we cannot schedule the notification unless the app is running. Therefore we would need the great good luck to have the app running at 6:59 AM in order for this app to work. But an app only runs when the user summons it, so that is extremely unlikely.
Therefore a task of this kind is possible only with remote notifications. A remote server is always running; therefore it can get the temperature and "ping" the user's device at 7 AM, and the system will present the notification on your behalf. You would therefore need to possess such a server in order to write the imagined app.
(An alternative using local notifications would be this: You schedule, say, a week's worth of local notification in advance. Then if you have the great good luck to find the app running before a notification is presented, you tear down all the scheduled notifications and do it again with a more up-to-date forecast. But of course this cannot possibly work as well as using remote notifications, and it will stop working entirely after a week if the user doesn't launch the app. That, to put it bluntly, sounds pretty lame.)

Supress Trello API Notification when renaming card

I made a little program to synchronize our internal time reporting system with Trello (SCRUM addon) and everything works fine. It basically takes the estimated hours per card from Trello, synchronizes the cards name with our internal system and then updates Trello with the actual hours used per card.
The problem is that each update of the card names triggers a Trello notification. Is there any way to suppress this behaviour? Ideally I'd want our system to update the Trello board right away when someone reports some spent time but as it is there are too many unnecessary notification emails being sent.
I was thinking that it could either first remove all notifications, make the subject changes and then readd notifications or is there some way to globally tell Trello to ignore making notifications for changes done with the Trello API?
Kind regards
Mats Forsén
There's no way to do that through the API, but a recent change to when notifications are generated means that this should no longer be a problem.