My question is very simple but unfortunately I don't find any answer around the Internet. I have an app alerts the user you amount is due based on invoice date in the database. The problem is how can I check periodically while the app in the background. I tried beginBackgroundTaskWithName but it expires after max 10 munites and also I tried back ground fetch but it doesn't work in proper time manner, so may be it takes a day to fetch again.
I really need your help in this.
Thanks in advance
Related
I am creating an idle game (user is rewarded for offline time with ressources). For that calculation I will need the elapsed time since the app was closed.
My first idea was to save the current time when the app is closed and read the current time when the app is opened. But what if a malicious user changes the system time between those actions? The user could get as many ressources as he wants with this trick.
My solution would be to consult a time server to get its current time when closing and opening the app. But this would mean the app would need to be always online, which I am trying to avoid.
Is there any other way I could use to accomplish this?
I don't think it means that the app always needs to be online. You just take the server time when the user closes the app and you take the time when the user opens the app again. You then subtract the first from the latter and then you have the offline time. Assuming of course that you save the "last_closed" time in a database of some sort.
When you are online you read correct time from an api which shows greenwich time not from user's device; so that you always have correct time.
Is it possible to have an App (running iOS4 on hardware supporting multi-tasking) which starts on iPhone startup and then regularly checks for online updates (every 15 minutes) and then refresh the badge, so the user can see how many unread items there are with-out having a push-server?
I was hoping this would be possible with iOS4 Programming Guide seems to suggest it is only possible to to this regarding Locations tracking, VoIP and playing background audio. There is also the possibility to do local-push notifications, but I don't see to find how to trigger a specific function that way.
Thanks in advance for any help!
edit:
Just having read a bit more, if the application is in the background/inactive state, and I son want to update the badge-number without displaying a message, is there an action triggered like didReceiveLocalNotification? There must be a way to schedule something on a regular basis (like email checking) without having to implement a full server-push-nitification system!
Is it possible to have an App ... which starts on iPhone startup and then regularly checks for online updates (every 15 minutes) and then refresh the badge
As you already figured out, the answer is no.
I have an app that requires me to take an action after some period of time. For example, if an user hasn't been inside the app in few weeks, when the user eventually starts the app, I have to ask them to put in a special code that was given to them when they installed this app. (this is an in-house app and i am being required to do this due to security concerns)
I am using the [NSDate date] method to retrieve the date when the user logs in and save it into a database. I compare this saved date next time they open up the app and see how long its been since their last login. The problem is that [NSDate date] gives the time that is effected by the time settings that can be changed manually by the user in the native settings app. As you can probably tell, this causes lots of problems to my situation. If the user is suppose to be put the special code after 3 weeks of inactivity, he can cause the app to show this screen by modifying the time in the native settings app or worse, get away from it by setting the time to a previous date that will be within 3 weeks of his activity.
Is there a way to get the "system time" instead of the "user time"? I have looked into mach_absolute_time() but this gets reset after restart of the device. Since the time of inactivity I will be comparing against is pretty large, chances are device would have been restarted by then. I also thought of using network connection to get the time from servers outside the app, but lots of users won't have access to wifi where they use their iPads. That will be my last resort solution if i can't find anything else. Because of their location during usage, I am trying to use everything on the device itself.
Am I overlooking something simple here? this seems too simple of a problem to not have an answer. Please guide me toward the right direction. Thank you in advance.
Why not query a remote server for the time - lots of NTP servers about or just make a simple HTTP request to a php script on your own server. Of course if your app is likely never to be connected to the internet that could be a problem, but once you have a 3rd party time its quite easy to guess if the user has been playing with the clock.
If this is an inhouse app (so you aren't constrained by Apples approval process), you could mark your app as doing some background stuff (voip or receiving location updates), so that the app will always be active and you'd be able to update some sort of an "unused" counter. Voip app will even be restarted by the OS after device reboot.
But of course it'll drain the battery somewhat.
Either: make having the actual time an essential feature of your app. This way the users will have a need to keep the time of the device current and can't go back three weeks
Or: mark the code as expired and save this information before the app informs the user. This will stop most user from setting the time back. Most will try once or twice, see that the app stays disabled and will give up.
You can also save the timestamp of the last successful execution and if that is more than a reasonable time frame in the future (remember summer/winter time) then consider it a "hack attempt". Put a CRC check (or whatever obscure idea you come up with) on that timestamp and save it too and you will stop a large number of script kiddies.
You can never stop the diehard hacker who search actively for every trick you might have put into the app. Just focus on the "average" user.
First ,this is my friends idea ,girls always use cell phone talk too much
every month they receive the billing will cost them a lot of money
they ask me is there any applications to calculate how long they dial out a month
or maybe can pop up a alert to notice them time is up,please hang up the phone
maybe 3 mins or 5 mins (some telecommunications provider offer free talk at first 3 mins )
So.......is it possible to use application to record your talking time and give you a notice ?
I'm just a new iphone programmer ,I have no idea about this ~
Even if this is impossible , still can share some information to me
It's help me to answer my friend
thanks :)
Using the wireless company's website would be the simplest way. If you really wanted a native iPhone app that would track time you could probably write one that utilized iOS's new multitasking abilities.
Essentially, the 10,000 foot view of the app would be something that a user would launch before making a phone call. When launched, they could start a timer (or delayed timer), move the app to the background (by tapping on the home button on a iDevice that supports background apps). The app's timer would continue to run in the background while the user makes their phone call.
I believe phone calls can be moved to the background as well, so users could go back to the app and check how much time they've been on the phone call.
Complicated, but doesn't require jail breaking. The implementation could be improved a ton, but that's the 1 minute, proof of concept, that you seemed to be looking for.
I'm thinking about building an iphone app that would use the GPS feature to track where someone is and for how long. I realize I could probably get the current location from the iphone from a website but the only way I'm familiar with is using ajax calls, etc (Sorry if this is a rather newbie concept) but I fear that would bog down my servers with constant calls to track time. Is there a better way to do this? Any resources I could consult on this idea/concept? Is it even plausible at this point?
I'm more versed in php/mysql but trying to branch out on some new ideas I've had. Any help would be greatly appreciated!
You could keep a local datastore then only send updates to the server when the app detects that the user has moved. I'm pretty sure that would work and on the server side you just work out the last time a user checked in and then compare that against the current time to see how long they have been somewhere. The only technical issue I can see with this is that this requires the user to have the iphone on and the app open the ENTIRE time they are somewhere, which would mean the iphone is now just a rather expensive GPS tracker with a built in phone!
you could store user locations on a local list on the iphone and once an hour you send the list with location/timesptamp pairs to server.
As James Raybould says, you can compute on server how long a user stayed inside a range for a given position. And also by sending data once an hour... not each time the iphone detects that user moved, then you save your server for continuously pings.