skip to Main Content

I receive this error when importing FamilyControls in my Expo Native module

[FamilyControls] Failed to get service proxy: Error
Domain=NSCocoaErrorDomain Code=4097 "connection to service named
com.apple.FamilyControlsAgent" UserInfo={NSDebugDescription=connection
to service named com.apple.FamilyControlsAgent}

How can I use FamilyControls from Apple in my React Native Expo Application ?

Currently i try to import it like this in my react native expo module.

import ExpoModulesCore
import FamilyControls
public class ExpoScreenTimeApiModule: Module {
  
  public func definition() -> ModuleDefinition {
   let center = AuthorizationCenter.shared
    Name("ExpoScreenTimeApi")
    
      AsyncFunction("requestScreenTimePermission") { () -> String in
      let center = AuthorizationCenter.shared
      do {
        try await center.requestAuthorization(for: .individual)
        return "Permission Granted"
      } catch {
        throw error // This will be caught as a Promise rejection in JavaScript.
      }
    }
  }
}

2

Answers


  1. Chosen as BEST ANSWER

    I resolved the issue, by applying to the apple developer program. Furthermore I started the app via

    expo run:ios --device

    selecting my physical device. Additionally I had to add Family Controls as capability in xCode.


  2. Family Controls framework is not part of the Expo modules, and it is not possible to use it directly in an Expo application.

    The Family Controls framework is part of the Screen Time framework in macOS, which allows developers to access information about the user’s screen time usage. This framework is not available in iOS or Android, and it is not possible to use it in a React Native Expo application.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search