Hi!
I'm exploring options to prevent date tampering on my app. One of those options involves obtaining the uptime of the device using sys/sysctl.h which I understand is an approved and supported way to do for macOS but I'm not sure if it would be approved during an Apple Review for my iOS app.
Does anyone know or have experience with this? Is it ok or will it get my app rejected?
I leave my code as reference here:
#include <sys/types.h>
#include <sys/sysctl.h>
+ (time_t)uptime
{
struct timeval boottime;
int mib[2] = {CTL_KERN, KERN_BOOTTIME};
size_t size = sizeof(boottime);
time_t now;
time_t uptime = -1;
(void)time(&now);
if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) {
uptime = now - boottime.tv_sec;
}
return uptime;
}
Thanks for any help you could provide
2
1
2.7k