ios 如何在 React Native 应用程序中制作“评价此应用程序”链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35612383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 08:35:26  来源:igfitidea点击:

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

iosapp-storereact-native

提问by vtambourine

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

如何在 iOS 上的 React Native 应用程序中将用户正确链接到 App Store 应用程序的评论页面?

采纳答案by SerzN1

For iOS you Have to add LSApplicationQueriesSchemesas Array param to Info.plistand add items to it.

对于 iOS,您必须将LSApplicationQueriesSchemes作为数组参数Info.plist添加到其中并向其添加项目。

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

例如到 AppStore 链接,我itms-apps用作此数组中的参数之一。

Your link should be like this

你的链接应该是这样的

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

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

回答by outofculture

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

使用链接打开应用商店的 url。要构建正确的 url,请按照iOS和/或android的说明进行操作。例如

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

or

或者

Linking.openURL('itms-apps://itunes.apple.com/us/app/apple-store/myiosappid?mt=8')

回答by Simar

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.

这是类似的东西,它显示一个警报框来更新应用程序,并根据他们的设备操作系统打开 Play 商店或应用程序商店。

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

回答by Nabeel K

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.

我正在使用这个。看起来不错。您只需要指定包名称和应用商店 ID 并调用该函数。而且它也是跨平台的。

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