DocuSign API return URL 在重定向后将控制权从 WebView 转移回 React-Native 应用程序
DocuSign API return URL that transfers control back from WebView to React-Native app after redirection
我正在使用 React-Native 构建一个 Android 应用程序。我也在使用 DocuSign Java API。
我的工作流程提交了一个 RecipientViewRequest 并收到了一个 URL,android 应用程序必须在 WebView 中查看该请求才能执行签名:
https://github.com/docusign/docusign-rest-recipes/blob/master/core_recipes/CoreRecipes.java
https://facebook.github.io/react-native/docs/webview.html
这是代码:
'use strict';
var React = require('react-native');
var {
StyleSheet,
View,
WebView,
Component,
} = React;
class DocuSignView extends Component {
render() {
var recipientViewURL = this.props.route.data.url;
console.log('Recipient URL is: ' + recipientViewURL);
return (
<View style={styles.container}>
<WebView
source={{uri: recipientViewURL, method: 'GET'}}
scalesPageToFit={true}
javaScriptEnabled={true}
domStorageEnabled={true}
>
</WebView>
</View>
);
}
}
DocuSign 服务器将 WebView 重定向到我提供的 returnURL
。
我如何指定 returnURL 来 return 控制回我的 React-Native android 应用程序?
(React-Native 的通用答案 iOS 或 Android 会更好)。
您将需要配置自定义URL 方案。
Android:http://developer.android.com/training/basics/intents/filters.html
对于iOS:http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
一种选择是使用 onNavigationStateChange 事件处理程序从 WebView 拦截和获取控制权:
render() {
var recipientViewURL = this.props.route.data.url;
console.log('Recipient URL is: ' + recipientViewURL);
return (
<View style={styles.container}>
<WebView
source={{uri: recipientViewURL, method: 'GET'}}
scalesPageToFit={true}
javaScriptEnabled={true}
domStorageEnabled={true}
onNavigationStateChange={this.whenNavigationStateChanges.bind(this)}
>
</WebView>
</View>
);
}
whenNavigationStateChanges(navState){
var navigator = this.props.navigator;
var parsed = Url.parse(navState.url, true);
if (parsed.hostname == 'YOUR_HOSTNAME'){
console.log("Event is: " + parsed.query.event);
navigator.pop();
}
}
我正在使用 React-Native 构建一个 Android 应用程序。我也在使用 DocuSign Java API。
我的工作流程提交了一个 RecipientViewRequest 并收到了一个 URL,android 应用程序必须在 WebView 中查看该请求才能执行签名:
https://github.com/docusign/docusign-rest-recipes/blob/master/core_recipes/CoreRecipes.java
https://facebook.github.io/react-native/docs/webview.html
这是代码:
'use strict';
var React = require('react-native');
var {
StyleSheet,
View,
WebView,
Component,
} = React;
class DocuSignView extends Component {
render() {
var recipientViewURL = this.props.route.data.url;
console.log('Recipient URL is: ' + recipientViewURL);
return (
<View style={styles.container}>
<WebView
source={{uri: recipientViewURL, method: 'GET'}}
scalesPageToFit={true}
javaScriptEnabled={true}
domStorageEnabled={true}
>
</WebView>
</View>
);
}
}
DocuSign 服务器将 WebView 重定向到我提供的 returnURL
。
我如何指定 returnURL 来 return 控制回我的 React-Native android 应用程序?
(React-Native 的通用答案 iOS 或 Android 会更好)。
您将需要配置自定义URL 方案。
Android:http://developer.android.com/training/basics/intents/filters.html
对于iOS:http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
一种选择是使用 onNavigationStateChange 事件处理程序从 WebView 拦截和获取控制权:
render() {
var recipientViewURL = this.props.route.data.url;
console.log('Recipient URL is: ' + recipientViewURL);
return (
<View style={styles.container}>
<WebView
source={{uri: recipientViewURL, method: 'GET'}}
scalesPageToFit={true}
javaScriptEnabled={true}
domStorageEnabled={true}
onNavigationStateChange={this.whenNavigationStateChanges.bind(this)}
>
</WebView>
</View>
);
}
whenNavigationStateChanges(navState){
var navigator = this.props.navigator;
var parsed = Url.parse(navState.url, true);
if (parsed.hostname == 'YOUR_HOSTNAME'){
console.log("Event is: " + parsed.query.event);
navigator.pop();
}
}