Background task to query a firebase database periodically / interval

I am working on a marketplace app (similar to Facebook Marketplace app, but in a specific context) , built in Ionic / Firebase, where users post items and other users opt-in to receive notifications about posted items within a specific radius (10km to 100 km) from their location (as soon as an item is posted).
When an item is posted, the user posting the item, specifies the location of the item.
When users register in the app, they specific their location, to be able to receive notifications based on their distance / radius from the posted item.

I am wondering how to implement this functionality. I can see 2 options:

Option 1: implementing this in a back-end Firebase Cloud Function - as soon as an item is posted:
1a. - find all users who have specified 10kms radius from the posted item - add them to a list of notified users
1b - repeat 1a for radiuses 30kms - 100kms from the posted item - add them to the list of notified users
1c - remove duplicates from list
1d - send notifications to users in list.
this has to be done for each and every item posted and is a massive overkill so is not my preferred approach.

Option 2: implementing this as a periodic query on users’ mobiles. Every number of minutes (e.g. 5 mins), query Firebase for newly posted items within the user’s specified distance / radius. Here I have the context of the specific user and their specific preferences (unlike in the back-end).
2a - implement a task running in the background, which makes the query to Firebase to find newly posted job within the user’s specified distance / radius.
2b - if new items found, invoke local notifications on the user’s mobile

My concern is with regards to option 2:

  • is it OK to have a background task doing that?
  • am I going to be able to submit the app to the stores? Apple is very strict on background tasks, I understand
  • which plugin should I use for that? Cordova / Capacitor?
  • Other concerns I should be aware of?

Has any one had this type of challenge in the past or suggestions how to implement / overcome it?