You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
While testing for SDK availability, an IllegalStateException occurs when attempting to check or initialize the Health Connect SDK. The app crashes unexpectedly instead of handling the error gracefully.
To Reproduce
Steps to reproduce the behavior:
Attempt to use authHealthConnect function when Health Connect is not installed or needs an update.
Observe the crash with the following error message androidx.health.platform.client.impl.ipc.internal.ServiceConnection in connect
Expected behavior
When the Health Connect SDK is unavailable, a popup should appear informing the user to download or update Health Connect. The app should not crash.
Code
export const authHealthConnect = async e => {
try {
const status = await getSdkStatus();
if (
status === SdkAvailabilityStatus.SDK_UNAVAILABLE ||
status === SdkAvailabilityStatus.SDK_UNAVAILABLE_PROVIDER_UPDATE_REQUIRED
) {
Alert.alert(
'Health Connect Not Available',
'Please check if Health Connect is installed.',
[
{
text: 'Download Health Connect',
onPress: () =>
Linking.openURL(
`market://details?id=${HEALTH_APP_BUNDLE_ID.HEALTH_CONNECT}`,
),
},
{text: 'OK'},
],
);
throw {
success: false,
sdk_unavilable: true,
message:
status === SdkAvailabilityStatus.SDK_UNAVAILABLE
? 'SDK is not available'
: SdkAvailabilityStatus.SDK_UNAVAILABLE_PROVIDER_UPDATE_REQUIRED
? 'SDK is not available, provider update required'
: '',
};
}
await initialize();
await requestPermission(
options?.scopes?.map(recordType => {
return {accessType: 'read', recordType};
}),
);
const permissions = await getGrantedPermissions();
if (permissions?.length) {
return {
success: true,
permissions,
};
}
throw {
success: false,
};
} catch (error) {
revokePermissionsHealthConnect()
return {
success: false,
error,
};
}
};
Screenshots
Environment:
Health Connect Version:"^2.1.0"
React Native Version: "0.74.3"
New architecture enabled: Yes/No
Using Expo: No
Android API Level: Android 13
The text was updated successfully, but these errors were encountered:
Describe the bug
While testing for SDK availability, an IllegalStateException occurs when attempting to check or initialize the Health Connect SDK. The app crashes unexpectedly instead of handling the error gracefully.
To Reproduce
Steps to reproduce the behavior:
androidx.health.platform.client.impl.ipc.internal.ServiceConnection in connect
Expected behavior
When the Health Connect SDK is unavailable, a popup should appear informing the user to download or update Health Connect. The app should not crash.
Code
Screenshots
Environment:
The text was updated successfully, but these errors were encountered: