I have an app that uses React Native' Native Module.
Currently the logic is that the Data type will be obtained from my enum as shown below
export declare enum HKQuantityTypeIdentifier { HeartRate = "HKQuantityTypeIdentifierHeartRate" }const requestAuthorization = ( read: (HKQuantityTypeIdentifier)[], write: HKQuantityTypeIdentifier[] = [] ): Promise<boolean> => { const readAuth = read.reduce((obj, cur) => { return { ...obj, [cur]: true }; }, {}); const writeAuth = write.reduce((obj, cur) => { return { ...obj, [cur]: true }; }, {}); return NativeModule.requestAuthorization(writeAuth, readAuth); }; const MyHealthLibrary: ReactNativeHealthkit = { requestAuthorization } export default MyHealthLibrary;
Front-end call:
await MyHealthLibrary.requestAuthorization([HKQuantityTypeIdentifier.HeartRate]);
This will give my expected result
Now i do not want to call the function from my front-end with the entire type "HKQuantityTypeIdentifier.HeartRate" instead i just want to call it like "HeartRate". Something like below:
await MyHealthLibrary.requestAuthorization(["HeartRate"]);
How do i achieve this??? Any help would be great!