react-native - 如何将 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?
解决方案
不是很清楚你的问题。但是如果你想在 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 }}
/>
)
}
}
推荐阅读
- android - Flutter:处理清单失败
- google-cloud-firestore - Firestore分页-如何在查询后查找是否有更多数据(使用限制)
- c++ - C++ 零初始化具有可变数组长度的模板数组
- javascript - 如何让菜单在移动设备上向下滑动并在桌面上向右滑动?
- sql - 如何在 BigQuery 中解析位于 ("%m/%d/%Y %H:%M:%S") 的 CURRENT_DATETIME()
- batch-file - Cmd 合并 .txt 文件并删除行
- javascript - 有没有办法在 ASP.NET 中从 C# 运行 JavaScript 函数?
- android - 使用Android Maven Plugin 4+的android项目中非标准位置的文件或文件夹
- c# - 使用实体框架从修改列表中更新数据库表
- android - 使用 vue.js 和 android 的移动应用程序的区别