Skip to content

Commit

Permalink
Android: Fix requestAuthorization not returning a result on success
Browse files Browse the repository at this point in the history
  • Loading branch information
SlimShadyIAm committed Aug 8, 2024
1 parent 0f5fb5a commit 6aa6d77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/health/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ android {
namespace "cachet.plugins.health"
}

dependencies { def composeBom = platform('androidx.compose:compose-bom:2022.10.00')
dependencies {
def composeBom = platform('androidx.compose:compose-bom:2022.10.00')
implementation(composeBom)
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
handler?.post { mResult?.error(errorCode, errorMessage, errorDetails) }
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
return false
}

/** Handle calls from the MethodChannel */
override fun onMethodCall(call: MethodCall, result: Result) {
when (call.method) {
Expand Down Expand Up @@ -546,6 +542,11 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
* type.
*/
private fun requestAuthorization(call: MethodCall, result: Result) {
if (context == null) {
result.success(false)
return
}

val args = call.arguments as HashMap<*, *>
val types = (args["types"] as? ArrayList<*>)?.filterIsInstance<String>()!!
val permissions = (args["permissions"] as? ArrayList<*>)?.filterIsInstance<Int>()!!
Expand Down Expand Up @@ -617,6 +618,8 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
return
}

// Store the result to be called in [onHealthConnectPermissionCallback]
mResult = result
healthConnectRequestPermissionsLauncher!!.launch(permList.toSet())
}

Expand Down

0 comments on commit 6aa6d77

Please sign in to comment.