Device Activity Report View Size and Background

Hello! I am a new developer and am attempting to use Apple's Device Activity API. However, I am struggling with the View of the Device Activity Report. For one, the view stretches to fill all available space instead of simply being the size of its content. Secondly, the background color seems fixed and I can't figure out how to remove it. The Screen Time API demo video shows this Device Activity API used with a clear background, so I know it is possible, I just can't figure out how to do it as it seems to be built into the Device Activity Report itself. Does anyone have any ideas? I'll attach a photo to show you what I mean. The black box is the Device Activity Report that I am trying to edit. Thank you for your help!

Add a Comment

Replies

Hey ! This is due to the fact that those views are rendered of process, you need to assign a fixed size to your view, and cannot assign a background color.

We opened a bug report for those exact things a while ago but didn't get any answers (FB10819848 (DeviceActivityReportScene doesn't behave like a regular SwiftUI view in an undocumented way), opened 06/22/22)

I invite you to open a bug report as well !

Regards

  • Thank you so much! That's really helpful to know, glad I wasn't just missing something obvious. I will open a bug request as well because it would definitely be helpful to get that fixed. Thanks once again for the help, you saved me a lot of future wasted time!

Add a Comment

@caleb4hzglory How do you able to get data from the DeviceActivityReport Extension? I always have empty content view. Can you share to me your code snippet how you do it? Thanks

  • Hey Joseph! So sorry it took me so long to see this. I've had a very frustrating time trying to figure out how to use Apple's various Screen Time API frameworks, so I am happy to help! This was the GitHub file that helped me the the most in setting up my application. I altered it for my app, but it helped a lot. If you are still struggling after looking this over let me know and I'm happy to help where I can!

    https://github.com/PedroSomensi/DeviceActivity

Add a Comment

Hi @caleb4hzglory, yh im having same issue as @JosephCa not being able to see anything from my content view when i add the DeviceActivityReport. Can you share with us some code snippet or idea how you get working on physical device please thank you

  • Hey Tim! I just answered Joseph's post above so hopefully that helps!

Add a Comment

im getting a black background when I call DeviceActvitiyReport(.init("...")) no matter what I do. It seems to be overriding (generating on top of) any background i set that view. any ideas?

  • Hey! That was my issue as well, and I didn't find a solution to it. I've basically tried to work my app around these limitations, but if anyone finds a solution, trust me, I would be thrilled. If you are getting the black box in dark mode you should be able to flip your device to light mode to get a white box if that helps. If one of the two colors is better for you, you can also lock you app in light or dark mode to keep it that way for your users. Hopefully this helps some!

Add a Comment