activitywatch icon indicating copy to clipboard operation
activitywatch copied to clipboard

iOS support

Open ErikBjare opened this issue 2 years ago • 16 comments

We currently support every major OS, except iOS.

Apple has historically taken a very cautious stance with ScreenTime data they collect, so support for iOS has been practically impossible (although RescueTime and some others offer an iOS app, it's really mostly a companion app).

However, a couple weeks ago someone gave me notice of Apple finally creating a more comprehensive API: https://www.reddit.com/r/QuantifiedSelf/comments/v1jykz/granular_app_tracking_on_iosipados/ibwbu2p/

The actual API: https://developer.apple.com/documentation/deviceactivity/deviceactivitydata

So, looks like this will be possible going forward. I don't personally own an iOS device, nor do I know anything about iOS dev, but going off how we built aw-android, we can probably do something similar for iOS, eventually.

ErikBjare avatar Jun 23 '22 09:06 ErikBjare

+1 on this! iOS App would be amazing! :) Does it look like this could come anytime soon per your roadmap - say anytime next year? @ErikBjare

ashutoshsaboo avatar Oct 13 '22 07:10 ashutoshsaboo

+1 this would be huge !

alexlyee avatar Nov 02 '22 03:11 alexlyee

I looked into this today - this new API is unfortunately quite limited. It doesn't at all give you full app usage data. What it allows you to do is basically just: a) set a time interval to monitor within, b) trigger callbacks when certain apps exceed a configurable time threshold within this interval.

It seems to be designed to allow a limited use-case of parental control apps that set limits on app usage during certain parts of the day, while restricting access to usage data as much as possible outside of that use-case. In theory you could abuse this API by setting really short intervals and adding all the apps on your phone with similarly short thresholds, but it looks like they block that route too (Attempting to monitor too many activities or activities that are too tightly scheduled can cause this method to throw an error). They don't say what the thresholds are, so maybe if they allow eg 15-minute intervals you could still get some useful data from this, but it would be pretty low-quality.

Confirming this conclusion (that this API is mostly useless for our needs) is the fact that I can't find any apps that are able to generate reports on app usage - if it were possible I think someone would have built it by now.

There are other hacky approaches (eg make a VPN and monitor network activity to infer app usage), and it's definitely possible that there's some hacky approach that would be disallowed in an app-store app review but maybe we could use if our users were willing to sideload the app. But I haven't yet found an approach that seemed good enough to bother trying.

zplizzi avatar Nov 07 '22 14:11 zplizzi

Thank you for your research!

alexlyee avatar Nov 07 '22 15:11 alexlyee

That said, it does seem to be possible to determine if the iOS device is actively in use - I think through (an abuse of) the location API. RescueTime seems to do this. So we could at least develop an AFK watcher for iOS, which imo would still be valuable. And since you're already accessing location data, you could also throw in location info, or an at-home/not-at-home indicator, which could be cool (but probably only updated when the phone is unlocked?).

It's not clear to me if there is a battery impact of always keeping location services on, though. The rescuetime app is broken for me or i would test it, lol.

zplizzi avatar Nov 07 '22 15:11 zplizzi

Ahhh damn. Thanks for digging through this @zplizzi, really appreciate it!

I guess we're back to square one after all. So much for my initial optimism, sorry for any false hopes!

ErikBjare avatar Nov 07 '22 16:11 ErikBjare

Looks like Timing supports iOS tracking now

https://timingapp.com/help/screen-time

Their approach is to ask the user to enable ScreenTime sync to Mac, then pull the data from the Mac via the Full Disk Access permission.

andrewschreiber avatar Jan 26 '23 18:01 andrewschreiber

@andrewschreiber We've tried doing the same in the past, but it was very unreliable/buggy data: https://github.com/ActivityWatch/aw-import-screentime

ErikBjare avatar Jan 27 '23 10:01 ErikBjare

Ah interesting! Wonder if it's improved since last year and/or better on iOS vs Mac (limitations in that readme seem to point to Mac issues)

andrewschreiber avatar Jan 27 '23 21:01 andrewschreiber

New AW user here! Tracking detailed usage from my iphone is one of my primary use cases for AW.

I'm playing around with https://github.com/ActivityWatch/aw-import-screentime to see what I can learn. I've got the old script working again, filed a PR and a couple issues.

I'll report back once I've had a chance to see how it actually behaves.

abegong avatar Feb 19 '23 21:02 abegong

FWIW, I've been trying out the Timing app (paid) and its iOS integration, and it's been really good for me so far. Seems to sync pretty quickly (usually have data within a couple hours or less) and no issues with data quality. Here's an example timeline it generates: image

zplizzi avatar May 24 '23 13:05 zplizzi

@zplizzi Really curious how Timing does it? Are they inspecting the database file like aw-import-screentime or something else? A new API? Any idea how long they've had the feature?

ErikBjare avatar Jul 21 '23 09:07 ErikBjare

There's a good many details here: https://timingapp.com/help/screen-time

Finally, grant Timing the "Full Disk Access" permission in System Settings. This is required for Timing to read your Screen Time database.

According to their changelog, looks like it was added on Jan 16 2023.

zplizzi avatar Jul 21 '23 14:07 zplizzi

Ah nice, that's a very extensive resource! But tl;dr seems same approach as aw-import-screentime (parse synced db file).

In my experience that data was very unreliable, but it's possible that it's due to us mishandling the data, which we might be able to fix (although reading the link it seems accepted that it's imperfect, still worth a try).

If someone wants to investigate that, we could make it work. I don't have an iOS device, so difficult for me to test extensively. Comparing the output of aw-import-screentime with Timely would be interesting.

ErikBjare avatar Jul 21 '23 18:07 ErikBjare

Comparing the Timing data and the data imported by aw-import-screentime, I can say that the results are quite similar.

One problem is that ActivityWatch reports about 15 minutes less than the Timing app. Another problem I've encountered is that the ActivityWatch Activity view doesn't show the Top Applications.

And judging by the Screen Time view on iPhone, it looks like this morning's data hasn't been synced yet.


Timing view:


ActivityWatch Activity view:
Real device UUID replaced with {uuid} for privacy reasons


ActivityWatch Raw Data (Timeline) view:
Category tag contains only the UUID of the device


ActivityWatch Raw Data (Events) view:
You should definitely check out the open-source Organic Maps app ;)


Screen Time data:

 

BelKed avatar Jul 25 '23 12:07 BelKed