Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

error handling in react native while accessing ios authorizations

$
0
0

I am running a React Native app.
I have defined a method "requestAuthorization" in my react-native-library. This method invokes healthkit to get the necessary authorizations.
This feature is only for ios. It does not support Android.

index.ts

const requestAuthorization = (  read: (healthTypes)[],  write: healthTypes[] = []): Promise<boolean> => {  const readAuth = read.reduce((obj, cur) => {    return { ...obj, [cur]: true };  }, {});  const writeAuth = write.reduce((obj, cur) => {    return { ...obj, [cur]: true };  }, {});  return Native.requestAuthorization(writeAuth, readAuth);};const MyHealthLibrary: iosHealthkit = {  requestAuthorization}export default MyHealthLibrary;

index.version.ts

const version = () => {  throw Alert.alert("Platform",'Platform "'+ Platform.OS +'" not supported',    [      {        text: "Cancel",        onPress: () => console.log("Cancel Pressed"),        style: "cancel"      }    ],    { cancelable: false }  );};const MyHealthLibrary: iosHealthkit = {  requestAuthorization: version};export default MyHealthLibrary;

So when i try to invoke "requestAuthorization" in Android it throws an Alert.
The Alert is working fine. But i get a warning below. I do not want that warning, i just want the alert. How can i remove the warning???

enter image description here

enter image description here


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>