0

I got a weird issue. My application is able to fetch everything from server when it is installed on Android version 5.0. However, the app cannot fetch anything from server when it is installed on Android version 4.4.

My server is using PHP code. My application is using React native code.

Here is the network code in my application which copied from React native network:

function getMoviesFromApiAsync() {
    return fetch('https://facebook.github.io/react-native/movies.json')
        .then((response) => response.json())
        .then((responseJson) => {
            return responseJson.movies;
        })
        .catch((error) => {
            console.error(error);
        });
}

When I replace the URL by my own one, the fetch function throws an error Network request fail even my real android device has strong network connection.

Here is my testing environment:

  • React native version 0.57
  • Android real device version 4.4
  • Real URL, not locahost

If there is any solution to make the api request work for Android version 4.4, please let me know.

Thank you in advance!

5
  • Does your app have the correct permissions? What happens if you open that URL on your phones browser? Commented Sep 27, 2018 at 2:24
  • 1
    @mblaettermann: My app has INTERNET permission. Do you have any suggestion about permission? The link works fine in browser of the application Commented Sep 27, 2018 at 2:34
  • Try use ip address Commented Sep 27, 2018 at 2:52
  • No, sorry I am no android expert. Commented Sep 27, 2018 at 3:01
  • 1
    @mblaettermann: You don't need to say sorry bro. I am appreciated your help Commented Sep 27, 2018 at 4:45

1 Answer 1

3

Thank you all, I found these links:

Android 4.x cannot fetch api

Why Android 4.x to fetch API - missing TLS

Solution for missing TLS

Actually, because Android 4.x has TLS 1.1 and 1.2 inside but not enabled, we cannot make a request to a server which has TLS 1.1 or 1.2. We need to enable them first in order to do that

Thank you again for all the comments. I really appreciate it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.