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

Api not working in IOS 13.5.1 using react-native - undefined is not an object (evaluating 'k.t14.response.data')

$
0
0

Everything works as expected in device and simulator but a friend of mine from different country seems to have trouble signing in using 13.5.1 ver devices only - and appStore also rejected saying that they could not sign in..

//Screen.js functionLogInFb = async () => { try {   await Facebook.initializeAsync("Id");   const {     type,     token,     expires,     permissions,     declinedPermissions,   } = await Facebook.logInWithReadPermissionsAsync({     permissions: ["public_profile", "email"],     behavior: "web",   });   if (type === "success") {     // Get the user's name using Facebook's Graph API     const response = await fetch(       `https://graph.facebook.com/me?access_token=${token}&fields=id,name,email,picture`     );     const res = await response.json();     console.log("sdf", res);     console.log("hfs", res.name);     const name = res.name.split(" ");     const payload = {       token: res.id,       last_name: name.pop(),       first_name: name.join(" "),       email: res.email,       picture_path: _.isEmpty(res.picture.data.url)         ? ""         : res.picture.data.url,     };     console.log("social auth payload", payload);     console.log("payload:" + payload);     //social Login error is here     await this.props.actions.socialLogin(payload);     // Toast.show("Login SuccessFul\n" + `Hi ${(await res).name}!`);   } else {     // type === 'cancel'   } } catch ({ message }) {   console.log("dsjf", message);   // Toast.show(`Facebook Login Error: ${message}`); }};//Action.jsconst socialLogin = (payload) => ({  type: SOCIAL_LOGIN_DATA_ATTEMPT,  payload: payload,});//Saga.jsexport function* socialLogin(action) {  yield put({    type: LOGIN_FETCHING_DATA,  });  try {    console.log(action, "alooasdfa");    const response = yield call(myAPI.socialLogin, action.payload);    const payload = response;    yield put({      type: SOCIAL_LOGIN_DATA_SUCCESS,      payload,    });    yield put(getProfileData());    NavigationService.navigate("Home");  } catch (e) {    Toast.showWithGravity(e.message, Toast.SHORT, Toast.TOP); // error show here on Toast    console.log("social login Errors:", e);    yield put({ type: SOCIAL_LOGIN_FETCHING_DATA_FAILURE });  }}//API.jsaxios.defaults.baseURL = "https://xxxxxx.com.au/api/";async socialLogin(payload) {    console.log("socialLogin", payload, {      headers: await HeaderData(),    });    try {      console.log("socialLogin", "/social_authenticate", payload, {        headers: await HeaderData(),      });      const res = await axios.post("v1/social_authenticate", payload, {        headers: await HeaderData(),      });      console.log("socialLoginResponse", data);      const data = get(res, "data");      await AsyncStorage.setItem("token", data.access_token);      const abc = await messaging().registerDeviceForRemoteMessages();      messaging().setBackgroundMessageHandler(async (remoteMessage) => {        console.log("Message handled in the background!", remoteMessage);      });      const deviceType = deviceInfoModule.getManufacturer();      const deviceUniqueId = deviceInfoModule.getUniqueId();      const tokenObj = await messaging().getToken();      const payloading = {        token: tokenObj,        device_type: deviceType === "Apple" ? "iOS" : "android",        device_identifier: deviceUniqueId,      };      console.warn("payloading", {        token: tokenObj,        device_type: deviceType === "Apple" ? "iOS" : "android",        device_identifier: deviceUniqueId,      });      const aaaa = await axios.post("/v2/register_device_token", payloading, {        headers: {"Content-Type": "application/json",          Authorization: "Bearer " + data.access_token,        },      });      console.log("socialLoginResponse", res, aaaa);      return data;    } catch (err) {      console.log("socialLoginError", err.response, err);      throw err.response.data;    }  }

error on Toast is undefined is not an object (evaluating 'k.t14.response.data')

I also asked my friend to visit other screens and there was error to fetch api so the problem mostly is not api is being called from 13.5.1 devices in his country.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



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