I'm writing the cache for an iOS app right now. I'm wondering how often i should refresh my cache. to give a little background, it's a weight loss app. what i'm working on right now, specifically, is a list of recipes. I pull the list of recipes from the server and display it in a table view. Obviously, i was going to make the list refresh when you pull down on the view controller. My question is, should i have it refresh the list every x number of days? or should it refresh every time the app is reopened? the list isnt expected to change more than once every 1 - 2 weeks, if that often. the user can also add their own recipes, so it could potentially change more often than that. is there a specific industry standard or protocol to follow for how often the cache should be refreshed?
Why don't you hook up your app with a Push Notification Service ? so incase there is a new recipe you could dispatch a push notification and when the user opens the app refresh your cache. That way you only refresh your cache when needed and also aids in better user experience. Here's a good tutorial on setting up a push notification service
Related
I have a basic query here. My app has a bit longer signup process. While testing I came across a bug where, whenever amidst the process if the user goes out of the app or kills the app, the remaining process is just left and it migrates to the a specific page, that i want the user to usually go to already.
Example if I have 5 ViewControllers and then a default 6th and if the users kills the app on 3rd VC, and then restart the app, it'll go to the 6th vc and ignore the rest of signup.
How do I avoid this. is using NSUserDefaults an optimal option. If yes How do i exactly implement it.
Cheers!
Yes, using NSUserDefaults to store the previous state of an app is common. (However, apps that have a server backend may store some data there too.)
Use the keychain to sensitive data (e.g. account details). (You must never ever store sensitive information in NSUserDefaults because it can be read.)
What you store in NSUserDefaults (and the keychain) depends on your application. If fields are filled in and/or options selected during the process, you need to store that.
Be pragmatic: It's very nice to users store app state. It can however get rather complicated. Don't waste time (with chances for bugs) trying to cover situations that don't occur often.
The documentation says that an app can ask a User three times per year via SKSToreReviewController to place a rating.
Most suggest to save a variable in UserDefaults and call the function after a couple of uses. What happens if you call the function more than three times per year? Will the App Store just ignore the calls and after a year asks for a rating again or will you get some kind of error?
And what happens if the app has been updated (ie. a jump from version 1.0 to version 2.0)? Will the 3 requests be reset?
In short, you choose the appropriate time to display the alert, but the system will decide whether to actually show the alert or not. So don't worry about "over-calling" as long as you don't call it as a response to user interaction.
Although you should call this method when it makes sense in the user experience flow of your app, the actual display of a rating/review request view is governed by App Store policy. Because this method may or may not present an alert, it's not appropriate to call it in response to a button tap or other user action.
Highlight mine.
https://developer.apple.com/documentation/storekit/skstorereviewcontroller/2851536-requestreview
As for your second question, the only reference I can find regarding how many times it might be displayed is "3 times per year". It doesn't mention 3 times per app version or update. Use this API wisely.
I am coding in Xcode 6.1.1 with objective-c.
In my app it is critical that I use the correct time.
I only want the app to use the time of the device when the time is synced with the servers.
If an user is somehow using his/her own "weird" time the app should detect that and tell the user to switch back to use the app.
I know there is NSSystemClockDidChangeNotification, but that only gives back when the time is changed. It does not give back what the change was and if the user switched to "custom" time or synced back to an NTP server.
Question: How do I detect if an user is connected to an NTP server or not?
Maddy is right that you can't specifically find this out from iOS.
However, in the past I've delivered a client for a premium subscription service that had a similar need to know if the user was messing with time. In particular we needed to verify this when there was no network available, in order to prevent the user from accessing premium content after their subscription had lapsed. The very simple mechanism we used was as follows (IIRC):
every time the app launches or comes in from the background, record the current time (eg: in NSUserDefaults)
compare the current time to the last recorded time--if the current time is earlier than the last recorded time, force the user to go online and sign in to the service.
I don't claim it is 100% foolproof, but for our purposes we felt it was good enough to prevent users from trying to circumvent time-based restrictions on accessing premium content.
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
I have a game where users can do a certain activity once per hour. How can I make sure it's been an hour since the last time they attempted something without them just changing their devices current time in settings?
Also, if I wanted to prevent the user from just deleting the app and re-installing it so they could constantly keep trying without having to wait to full hour is there any way I can store data on the device even after an app delete or would that have to be a server thing?
If I don't have a server can anyone think of a clever way to do this via Free in-app purchases or something?
The only way to persist data in a way that survives app reinstalls is to save it to the keychain. This works, because keychain data may be shared across multiple applications; the rest of your application's data is removed on uninstall.
If you need a reliable way to tell the current time, the device must be connected to the internet. In this case you would be able to check the current time using one of the time services through the NTP.
That sounds like exactly the sort of task you would need a server for.
When the user wants to perform this limited action, have them ask the server for permission. You can log the user's ID and request time, decide if they can execute the action, then return a small success/failure message. Works if they change their clock, works if they log in from a different device, works if they wipe the device data.