我的 WebView 应显示具有 cookie 身份验证的网页。该页面需要在登录时获取会话 ID cookie。为了进行身份验证,我使用 fetch() 将登录请求发送到网站。
登录成功后,我可以看到收到了正确的 cookie。成功后,我将启动 WebView。
它在 Android 上完美运行,但在 iOS 上却无法运行。
昨天我尝试了很多关于 SO 建议的不同方法,比如使用 react-native-cookies 手动获取 cookie,但没有任何帮助。
下面是一个与我的应用程序执行相同操作的示例组件。我认为问题可能出在我的应用程序的配置中,所以我创建了这个非常简单的示例,它也有同样的问题。
export default class App extends Component {
constructor(props) {
super(props)
this.state = {
response: null,
}
}
async componentDidMount() {
const response = await this.logIn()
console.log('LogIn completed', response)
this.setState({
response: response
})
}
async logIn() {
const url = 'myurl/login?email=email&password=password'
const headers = {'MyHeader': 'Header text'}
try {
let response = await fetch(url, {
method: 'POST', …Run Code Online (Sandbox Code Playgroud) 有没有办法禁用 WKWebView for iOS 和 WebView for android 的缩放?我正在使用 react-native-wkwebview-reborn。