I'm writing a library (maybe it'll be a barrel) which I also use in a datafield (for on-device settings input) and in other types of apps.
It uses a timer, which isn't available in datafields. When I try to create a timer I get:
var timer = new Timer.Timer();
Error: Permission Required
Details: Module 'Toybox.Timer' not available to 'Data Field'
This is OK, the rest of the functionality is still useful, but I am not able to catch the error and "Timer has :Timer" returns true. Is there a way to know programmatically that I am running in a datafield or check for whatever this required permission is or that I can use Timer.Timer?