How to make a “Rate this app” link in React Native app?

后端 未结 6 1227
无人及你
无人及你 2021-01-30 13:11

How to properly link a user to reviews page at App Store app in React Native application on iOS?

相关标签:
6条回答
  • 2021-01-30 13:53

    For iOS you Have to add LSApplicationQueriesSchemes as Array param to Info.plist and add items to it.

    For example to AppStore linking I use itms-apps as one of params in this array.

    For example:

    <key>LSApplicationQueriesSchemes</key>
    <array>
      <string>itms-apps</string>
    </array>
    

    Your link should be like this

    itms-apps://itunes.apple.com/us/app/id${APP_STORE_LINK_ID}?mt=8.

    Well. Now you have all stuff to do Link component with method

    handleClick () {
        Linking.canOpenURL(link).then(supported => {
            supported && Linking.openURL(link);
        }, (err) => console.log(err));
    }
    
    0 讨论(0)
  • 2021-01-30 13:53

    2021 Update:

    Some of the other answers are quite old, and don't support using the in-app review API added in iOS 10.3 (SKStoreReviewController) and Android 5 (ReviewManager). If you're adding reviews to your React Native app in 2021 you should ideally use these if they are available.

    Expo provide a library, https://docs.expo.io/versions/latest/sdk/storereview/ , which will use these newer APIs if they are supported on the user's device, and falls back to opening the store page if not.

    There is also https://github.com/KjellConnelly/react-native-rate which has similar functionality, but with a lot more configuration options. E.g. you can decide whether or not to use the in-app API some or all of the time (which might be a good idea, as the in-app API has a lot less friction for the user but you can only ask a few times a year).

    0 讨论(0)
  • 2021-01-30 13:56

    This is something similar, it shows an alert box to update the app and it opens the play store or the app store depending on their device os.

    function updateAppNotice(){
         const APP_STORE_LINK = 'itms://itunes.apple.com/us/app/apple-store/myiosappid?mt=8';
         const PLAY_STORE_LINK = 'market://details?id=myandroidappid';
         Alert.alert(
            'Update Available',
            'This version of the app is outdated. Please update app from the '+(Platform.OS =='ios' ? 'app store' : 'play store')+'.',
            [
                {text: 'Update Now', onPress: () => {
                    if(Platform.OS =='ios'){
                        Linking.openURL(APP_STORE_LINK).catch(err => console.error('An error occurred', err));
                    }
                    else{
                        Linking.openURL(PLAY_STORE_LINK).catch(err => console.error('An error occurred', err));
                    }
                }},
            ]
        );
    }
    
    0 讨论(0)
  • 2021-01-30 14:05

    Use Linking to open up the url to the app store. To construct the proper url, follow the instructions for iOS and/or android. E.g.

    Linking.openURL('market://details?id=myandroidappid')
    

    or

    Linking.openURL('itms-apps://itunes.apple.com/us/app/apple-store/myiosappid?mt=8')
    
    0 讨论(0)
  • 2021-01-30 14:06

    I am using this library. seems pretty good. You just have to specify the package name and App store ID and call the function. And it's cross-platform too.

    render() {
            return (
                <View>
                    <Button title="Rate App" onPress={()=>{
                        let options = {
                            AppleAppID:"2193813192",
                            GooglePackageName:"com.mywebsite.myapp",
                            AmazonPackageName:"com.mywebsite.myapp",
                            OtherAndroidURL:"http://www.randomappstore.com/app/47172391",
                            preferredAndroidMarket: AndroidMarket.Google,
                            preferInApp:false,
                            openAppStoreIfInAppFails:true,
                            fallbackPlatformURL:"http://www.mywebsite.com/myapp.html",
                        }
                        Rate.rate(options, (success)=>{
                            if (success) {
                                // this technically only tells us if the user successfully went to the Review Page. Whether they actually did anything, we do not know.
                                this.setState({rated:true})
                            }
                        })
                    } />
                </View>
            )
        }
    
    0 讨论(0)
  • 2021-01-30 14:10

    Using third party libraries, in ios it is opening itunes, let me tell you the exact way for opening appstore. First thing your should be live and it'll work on physical device(simulator is not guaranteed)

    const url = Platform.OS === 'android' ?
                        'https://play.google.com/store/apps/details?id=YOUR_APP_ID'   :  'https://apps.apple.com/us/app/doorhub-driver/id_YOUR_APP_ID'
                    Linking.openURL(url)
    

    You can find your ios link by searching your app on appstore and copy that url.

    0 讨论(0)
提交回复
热议问题