How to set up push notifications based on location in iOS? - ios

I'm writing an app in which users create postings which are geotagged and are stored on Firebase database. I want other users to be notified of these postings if they are in a nearby vicinity.
EDIT
How should I go about making such a function?
NOTE: I have managed to setup my app with push notifications and I have hooked it up to Firebase to receive "Message" from Firebase
Aditionally
I want users to tailor the notifications they receive to their prefrences based on features in the postings

This sounds like a job for geofencing!
Basically, you can set up a geofence which you can think of as an area that, if the user's device enters that area, triggers an action like sending a local iOS notification. It's nice in that it works even if your app is in the background. That said, it's probably a bit too much of a weighty topic to get into here, but there's a pretty good geofencing tutorial over on RayWenderlich.com that you should probably check out.
What you can do is have your app read in relevant locations from the database and then create a bunch of geofences to trigger these notifications when the user enters these locations. One important note, however, is that iOS limits you to 20 active geofences at a time, so you may need to do some work to determine what geofences are most relevant to your user whenever they use your app.

Related

user to user push notifications

I have seen many questions on here and online that address this topic, but they all are from a long time ago, and are possibly outdated. I wanted to get a more recent answer if Firebase has implemented anything recently that is capable of a user to user push notification system, essentially what is used in all chat applications, or if the best option is still currently using Onesignal.
Yes! These days, you can use Cloud Functions for Firebase to do things like send a notification when something interesting happens on the Database side of things.
Here's an example where a user gets notified via notifications when they gain a new follower. Obviously, your part of the database portion will probably change depending on what exactly you want to trigger a notification, but the general theory is the same.

iOS with Parse: users tracking each other

Please suggest the most efficient approach to implement different users tracking each other on the map, so every user can see others current location and they can see his.
For example: if one user moves, other immediately see his new location and vice versa. If the user moves and new users appear in his vicinity, they are tracked.
I would like to use Parse as a backend for this.
I tried the approach of saving new location on didUpdateUserLocationand then running a query in background, configured as myQuery.whereKey("location", nearGeoPoint: currentGeoPoint, withinKilometers: 0.5)
It works but apparently uses lots of bandwidth, as even a small change in user location triggers a query to Parse (and i see internet activity indicator on iPhone status bar working all the time).
So i have a feeling that it can be way more efficient.
Should i use push notifications instead?
If so, what would be the implementation in general?
Thanks a lot!
If you want to monitor location changes in realtime, then this will of course require a substantial amount of interaction with the remote server. While Parse may or may not be a good backend for this task, you should keep in mind that, if you are using the free plan, you have a limit of 30 API requests/second (and this may easily be exceeded in this scenario when you have multiple users).
Limiting the updates to significant location changes may be a reasonable compromise, as described in the documentation. Here, you would get a new location when the user moved ~500m, but this could of course be the downside when you want to literally follow the user in person.
Using push notifications to inform other users of a user's location changes might be more efficient:
send a push notification to the followers once a user changes
her/his location. This would mean one request for each location
change.
update other users' location changes when your own
location changes. Here you would have two requests for each location
change.
Using 1, you would still get updates from other users, even when you are not on the move. Note that these requests are counted for the device, not for Parse. I.e. Parse includes sending push notifications in the request limit.

Find if user is near a certain location iOS

I want to make a app which will find nearby coffee shops and push notify users if found any within 1 mile.
I just wanted to make sure How it can be done
This is what I have thought about till now
Get users Location
Update every minute in background and find if changed
If changed, find nearby Stores from the database on server
If found any nearby Stores, Push Notify user on their phone.
1 notification per store, so if same store found in same location, it won't send push notification again.
Please do tell me, if this can be done. I'm just not sure about background location updating in background or even if the app is closed.
I will suggest that you take a look at Parse.com - A very mobile-friendly (both android, win and iOS) DB and library system. Easy to set up to user location and geolocation for your stores. Parse has an in-built push notification system, that works really easy, which could be triggered by how far you are from a store. Parse's DB is scalable and free to use until you reach a high level of user traffic in your app.
Take a look: Parse.com

iBeacon notification database

I have a question which I have not been able to figure out so I decided to see if I can get some help on here.
I am working on an iBeacons project and I have been able to understand the basic function of iBeacons, setting up UUID'S and major and minor id's to specify exact notifications, but my question is how do I dynamically update information I send out to the users without having to go into the code each time to do this. Do I need to create a database to store all my information I want to push out to users? if so how will this database constantly refresh messages pushed out to users? An example would be lets say if you walk into a store and you get a notification in the shoe section saying there is a 10 percent off, you look at the notification but not too impressed and start to walk out, then you get another notification saying for today only you can get a 25 percent off... The app has to dynamically refresh for this to be possible.
Please help me clarify this
Thank you very much for the help
What you probably want is to store this deal information in a web service so you can update it without changing the app. Your app would need to download the updated deal information from the web service either when it starts up or when it sees an iBeacon.
My company, Radius Networks, offers a tool called Proximity Kit that makes this easy. You can assign arbitrary key/value pairs to iBeacons using a web interface. Then your app downloads them automatically an has access to them whenever you see iBeacons.
In your scenario, they key/values could be something like:
primary_offer_text=10% off all shoes
secondary_offer_text=20% off all shoes

Notifications on remote change

I'm developing an application which holds a list of objects.
The user should be able to favorite some of these objects, which then gets saved for easy access. Simple enough, right.
However, in addition to that, I want it so that the application notifies the user (using a notification, like when you get a new SMS), whenever one of the favorited objects have had something changed (in my application the objects represent a pub, and a change to the pub is when it has a new event scheduled). The change is done on a remote server, using a webpage.
When my app is active I can just poll the server every few minutes and compare the properties of the object, and if I see a change notify the user.
But how will I do to make this work when my app is NOT in the foreground? I want the user to get a notification even if he/she is not currently running my app.
The app does not have any login-functionality, so I can't send out specific push notifications to specific users. So the only thing the server might have access to is perhaps the device ID. I.e. there is no real way for the server to know which favorites a device ID holds.
Is there some smart way to do this? On Android I can just use polling but as iOS doesn't allow code to run in the background in the same way I don't really know how to do.
All help greatly appreciated. Even if it's just a "I don't think that's possible".
Just create a table that associates device ID with favorites. When a favorite changes, send that device ID a push notification
The user is the device ID

Resources