Notifications on remote change - ios

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

Related

How to set up push notifications based on location in 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.

How do I ensure that only one instance of an iOS app is running?

I have an iOS app that permits people to "claim points." I want to prevent a scenario where someone opens the app on their phone, another instance on an iPad and then submits claims in both places.
Presently the app "registers" as the active instance when it starts up. If a second instance starts, it will take control and any attempt by the first instance to save data will result in a redirect that tells the user not to have two apps open. I have seen some games (e.g. Clash) that immediately inform the user of the first app that they are being kicked the moment that the second app opens.
I can think of two ways to do this: submit a "heartbeat" every few seconds to see if we are still the controlling app (wasteful) and some form of notification to all other apps when a new instance opens. Can standard iOS notifications play this role or are they just for popping up notifications to the user?
Any insight into how to post a notice to all other instances of an app when one instance opens up that doesn't require polling would be appreciated!
You can manage this problem on the server side.
Apparently users have to login or at least, your app auto-login with a unique ID with a server.
If you have an API to receive a claim, you can simply check if an identical claim already exists for this Unique ID and return an error to the second device when that is the case.

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

Delete user from server if they delete app

Is it possible to delete a user from a server if they delete your app from their phone?
I am using UUID to create users so they do not have to register but I do not want users to delete the app then rejoin and have a new uuid while the old one is still in the database.
Are there any alternatives to using UUID to avoid registering. Apparently UDID which would have been ideal has been deprecated for IOS 6 and upwards.
Please help, thanks in advance.
Alternatively,
You can create a service in App that ping server once a day. if any device didnt respond from long time then delete it from database.
You can't know if user deleted your app or not. So the method you mentioned is not possible.
One-way is, if you are using any advertisement in your app, you will get the advertisement identifier. It's unique for a device, so if user installs your app again, you will get the same advertisement identifier and you can identify the user. But I won't recommend this method, as I can sell my phone at anytime and the new owner can use your app. But he will be considered as old user in this scenario.
So my suggestion is keep a login for individual users. There are a lot of pitfalls in this approach also. You can't identify whether the app is deleted or not. Also same user can create multiple usernames and use it from same device.
You can save DeviceId into database associated with your user and then check if that device is already registered, delete old one and set new UUID. You can get DeviceId like following:
[[UIDevice currentDevice] identifierForVendor].UUIDString;
This will be the same for all your apps(on the appstore) but unique for device
I think that you can't catch delete event with your application.
Also, check this link as well:
Can I know when the user delete my app?
instead of catching a delete event what you can do is store the user info in your database, if the same user tries to join again throw a prompt indicating the user is already present and don't allow him to sign up

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

Resources