How can I detect whether the iphone has been rebooted since last time app started

This seems like it would work:

  • get the time since last reboot, and for this example, let’s store it in a variable called ‘tslr’ (duration in milliseconds I guess, BTW, how do you get that?)
  • get the current time, store it in variable ‘ct’ for example
  • compute the last reboot time (let’s call it ‘lr’), we have: lr = ct – tslr
  • store ‘lr’

Next time your application gets started, load the previous value for ‘lr’, compute the new one, and if they differ, you have detected a reboot (you’ll probably have to tolerate a small difference there… a couple milliseconds perhaps).

I think it would be pretty tough to fool that… the user would have to tamper their phone time very precisely, and they would have to start your application at a very precise moment on top of that, exactly when the new ‘lr’ would be identical to the previous one… pretty tough to do, the probability of them being able to do that is very close to 0 I think. And you don’t need any internet connection to do that…

The new ‘lr’ would be identical to the previous one in the following cases only:

  • phone was not rebooted, and time was not changed
  • time was tampered with, AND the user managed to start your application at the precise millisecond to fool your algorithm (chances of that happening more than ultraslim)

Leave a Comment