Skip to content

how to get the screen time #6

Closed as not planned
Closed as not planned
@AftabUfaq

Description

@AftabUfaq

how can i get the screen time. For example how much time the user use his phone in last 24 hours and 7 days and in on month. i have successfully installed the dependency and get the permission but on which function you should get the time.

  useEffect(() => {
      requestScreenTime();
  }, []);

  const requestScreenTime = async () => {
    
    ScreenTime.requestAuthorization("individual").then(async () => {
      const status = await ScreenTime.getAuthorizationStatus()
      console.log('Authorization status:', status) // 'approved', 'denied', or 'notDetermined'
      let selection = await ScreenTime.displayFamilyActivityPicker("all");
      console.log('Family activity selection:', selection);
     // selection will be `null` if user presses cancel
      if (selection) {
        await ScreenTime.setActivitySelection(selection); // sets the shields
      
      }
    })
  }  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions