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

依然范特西╮ 提交于 2019-12-03 02:20:12

问题


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


回答1:


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.

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));
}



回答2:


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://itunes.apple.com/us/app/apple-store/myiosappid?mt=8')



回答3:


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));
                }
            }},
        ]
    );
}



回答4:


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>
        )
    }


来源:https://stackoverflow.com/questions/35612383/how-to-make-a-rate-this-app-link-in-react-native-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!