更新时间:2023-01-25 21:49:07
这似乎可以工作:
下次启动应用程序时,请加载'lr'的上一个值, ,如果他们不同,你已经检测到重新启动(你可能要忍受一个小的差异,有几个毫秒可能)。
我认为将非常难以愚弄那个...用户必须非常精确地篡改他们的电话时间,他们必须在非常精确的时刻开始你的应用程序,正是当新的'lr'将是相同的对前一个...很难做,他们能够做到这一点的概率非常接近0我认为。您不需要任何互联网连接就可以做到这一点...
在以下情况下,新的lr将与上一个完全相同: p>
I'd like to detect from within my app whether the iPhone has been rebooted since last time my app was started. I need to do this because my app uses the timer since last system reboot to clock a user's time and I want to detect reboot so I can invalidate the time.
Is there anywhere I could extract the information from the system console log like reboot , crashes ? The organizer in xcode can access it , maybe I can too.
If not , can you think of other ways to get this information?
This seems like it would work:
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: