如何解决如何在WebView中使用react-native
我正在为登录我的应用程序的用户使用Cognito和社交连接(Facebook,Google和signInWithApple)。 它可以正常工作,但是将用户带到浏览器进行登录。
我的应用在IOS应用商店中被拒绝,并显示以下消息:
Guideline 4.0 - Design
We noticed that the user is taken to Safari to sign in with Google,which provides a poor user experience.
Next Steps
To resolve this issue,please revise your app to enable users to sign in or register for an >account in the app.
We recommend implementing the Safari View Controller API to display web content within your >app. The Safari View Controller allows the display of a URL and inspection of the certificate from an embedded browser in an app so that customers can verify the webpage URL and SSL
certificate to confirm they are entering their sign in credentials into a legitimate page.
Resources
For additional information on the Safari View Controller API,please review the What's New in Safari webpage.
我们试图解决此问题,但我们的Web视图需要一个URL。我与Cognito的连接方法由Amplify:Auth method federate Sign in上的此文档定义。
所以我的代码以前是这样的:
import Auth from '@aws-amplify/auth';
[...]
const SignInForm = ({ styles,navigation,}) => {
[...]
<TouchableOpacity
style={{
backgroundColor: '#4286F3',borderWidth: 1,borderColor: '#4286F3',padding: 4,height: 40,margin: 8,width: '84%',borderRadius: 4,flexDirection: 'row',alignItems: 'center',}}
onPress={() => Auth.federatedSignIn({provider: 'Google'})}>
<Icon
size={28}
color='white'
name={'logo-google'}
style={{ marginHorizontal: 8 }}
/>
<Typography color="black" align="center" size="label">
{'Se connecter via Google'}
</Typography>
</TouchableOpacity>
我想在我的应用中使用Webview或以模式显示Webview。但是,问题仍然在于Cognito不能为我们提供URL,而只是为函数提供。我们如何解决这个问题?
我们有一个如下所示的浏览器组件:
import React from 'react';
import {WebView} from 'react-native-webview';
import PropTypes from 'prop-types';
const Browser = ({route}) => {
const url = ''
return <WebView source={{uri: url}} />;
};
Browser.propTypes = {
route: PropTypes.shape().isRequired,};
export default Browser;
如果找到该URL,则可以使用它在模式或Web视图中使用
navigation.navigate('Browser');
在onPress
中。
我不知道问题来自Cognito还是我们的代码。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。