2

I have an Apple Watch application which supports watchOS 2.0+ . I want to implement the autologout functionality in watch application.

I have used the sendEvent approach mentioned below for the iPhone app.

iPhone: Detecting user inactivity/idle time since last screen touch

As per my understanding there is no way in watchOS 2.0 where you can listen the touch event.

So anybody have an idea how we can implement the inactivity in WatchOS 2.0

Community
  • 1
  • 1
Rushikesh
  • 61
  • 4
  • I have implemented this using NSTimer and systemup time of watch.NStimer is stop working when your device is idle for long time then NStimer is stop working so we will have to use systemup time – Rushikesh Oct 21 '15 at 12:20
  • For systemup time you can use following function. `+ (NSTimeInterval)systemUpTime { struct timeval boottime; int mib[2] = {CTL_KERN, KERN_BOOTTIME}; size_t size = sizeof(boottime); struct timeval now; struct timezone tz; gettimeofday(&now, &tz); double uptime = -1; if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) { uptime = now.tv_sec - boottime.tv_sec; uptime += (double)(now.tv_usec - boottime.tv_usec) / 1000000.0; } return uptime; }` – Rushikesh Oct 21 '15 at 12:20

0 Answers0