0

In our React Native app, we have a link that directs the user to download a newer version of the app. The problem is that, in the Android build, this ought to point to the Play Store. In the iOS build, the link ought to point to the App store. Is there a way I can insert the appropriate links at build time? Here is the code where we use the link.

 _handleDownloadPress = () => {
    const url = 'https://xxxx.app.link/example';
    Linking.canOpenURL(url).then(supported => {
      supported && Linking.openURL(url);
    }, (err) => console.log(err));
  }

1 Answer 1

2

You can use the Platform check from react-native

https://facebook.github.io/react-native/docs/platform-specific-code

import { Platform } from 'react-native';

const url = Platform.OS === 'ios' ? 'https://ios.url' : 'https://android.url'
Sign up to request clarification or add additional context in comments.

2 Comments

Awesome. Thank you!
Yep. Stack makes me wait 8 minutes before accepting.

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.