request Permissions
Requests all necessary permissions from the user to access health data. This function should be called before attempting to access any health data.
Return
true if all required permissions were granted by the user, false otherwise.
Parameters
The platform context used to present the system permission UI. On Android this must be a ComponentActivity (Health Connect needs an activity to launch its permission flow). On iOS / watchOS the value is unused and may be nil.
Throws
if an error occurs during the permission request process.
Android (Kotlin)
lifecycleScope.launch {
try {
val granted = AFCore.healthTracking().requestPermissions(context = activity)
if (granted) startSyncing() else showError("Health permissions were not granted")
} catch (t: Throwable) {
showError("Could not request health permissions: ${t.message}")
}
}iOS (Swift)
Task {
do {
let granted = try await AFCore.shared.healthTracking().requestPermissions(context: nil)
granted ? self.startSyncing()
: self.showError("Health permissions were not granted")
} catch {
self.showError("Could not request health permissions: \\(error.localizedDescription)")
}
}Requests all necessary permissions from the user to access health data. This function should be called before attempting to access any health data.
Return
true if all required permissions were granted by the user, false otherwise.
Parameters
The platform context used to present the system permission UI. On Android this must be a ComponentActivity (Health Connect needs an activity to launch its permission flow). On iOS / watchOS the value is unused and may be nil.
Throws
if an error occurs during the permission request process.
Android (Kotlin)
lifecycleScope.launch {
try {
val granted = AFCore.healthTracking().requestPermissions(context = activity)
if (granted) startSyncing() else showError("Health permissions were not granted")
} catch (t: Throwable) {
showError("Could not request health permissions: ${t.message}")
}
}iOS (Swift)
Task {
do {
let granted = try await AFCore.shared.healthTracking().requestPermissions(context: nil)
granted ? self.startSyncing()
: self.showError("Health permissions were not granted")
} catch {
self.showError("Could not request health permissions: \\(error.localizedDescription)")
}
}Requests all necessary permissions from the user to access health data. This function should be called before attempting to access any health data.
Return
true if all required permissions were granted by the user, false otherwise.
Parameters
The platform context used to present the system permission UI. On Android this must be a ComponentActivity (Health Connect needs an activity to launch its permission flow). On iOS / watchOS the value is unused and may be nil.
Throws
if an error occurs during the permission request process.
Android (Kotlin)
lifecycleScope.launch {
try {
val granted = AFCore.healthTracking().requestPermissions(context = activity)
if (granted) startSyncing() else showError("Health permissions were not granted")
} catch (t: Throwable) {
showError("Could not request health permissions: ${t.message}")
}
}iOS (Swift)
Task {
do {
let granted = try await AFCore.shared.healthTracking().requestPermissions(context: nil)
granted ? self.startSyncing()
: self.showError("Health permissions were not granted")
} catch {
self.showError("Could not request health permissions: \\(error.localizedDescription)")
}
}