首页 > 解决方案 > 如何将 oAuth 会话令牌从 salesforce react native 应用程序传递给 react-native webview?

问题描述

我们计划开发一个自定义的 react-native 移动应用程序,我们需要通过 Lightningout.js 在移动 webview 中显示闪电应用程序页面。

我们使用 forcereact (Salesforce mobile sdk) 创建了一个 react-native 应用程序,我们可以成功登录并获取 OAuth 令牌。我们要求通过闪电输出在 react-native webview 中显示闪电组件页面。为此,我们应该将 oAuth 令牌安全地传递给 webview。有没有办法将令牌传递给 react-native webview?

标签: react-nativesalesforcesalesforce-mobile-sdk

解决方案


不是很清楚你的问题。但是如果你想在 html 页面和 react-native 之间进行交互。你可以使用 postMessage 和 onMessage。

export default class Test extends React.Component{
    constructor(props){
        super(props);
    }

    handleMessage(msg){

    }

    postMessage(msg){
        this.webview.postMessage(msg)
    }

    render(){
        return (
            <Webview 
                source={{uri:"http://test.com"}}
                onMessage={this.handleMessage}
                ref={ref => { this.webview = ref }}
            />
        )
    }

}

推荐阅读