我在用着react-native-oauth
并在尝试授权时收到此错误(请参见底部的红色图像)。我搜索过并只找到这个类似的未回答的问题 https://stackoverflow.com/questions/40905638/error-invalid-data-message-all-must-be-length-8-pickerios。我查看了来源并发现错误发生的地方 https://github.com/facebook/react-native/blob/master/React/Base/RCTBatchedBridge.m在第 954 行,似乎是因为moduleIDs.count
应该等于methodIDs.count
and paramsArrays.count
:
if (RCT_DEBUG && (moduleIDs.count != methodIDs.count || moduleIDs.count != paramsArrays.count)) {
RCTLogError(@"Invalid data message - all must be length: %zd", moduleIDs.count);
所以,还是在来源 https://github.com/facebook/react-native/blob/master/React/Base/RCTBatchedBridge.m,我查找这些对象并发现它们在上面的第 943-945 行定义,并且它们正在使用 RCTConvert,其函数“...全部接受 JSON 值作为输入并将其映射到本机 Objective-C 类型或类。 ”- React 的文档 https://facebook.github.io/react-native/docs/native-modules-ios.html
所以这似乎是一个与转译和/或网络相关的错误。但我对这些领域的知识基本上为零,感觉我在调查方面遇到了障碍,想知道是否有人有任何前进的想法。作为 React Native 的新手并且从未做过任何 Objective-C 对我来说没有帮助。
另外,这是我生成错误的代码。
import OAuthManager from 'react-native-oauth';
import {
Alert
} from 'react-native'
var env = require('../environment.js')
const config = {
facebook: {
client_id: env.getKey("FB_ID"),
client_Secret: env.getKey("FB_SECRET")
}
}
const manager = new OAuthManager('myAppName')
manager.configure(config);
exports.authWithFb = () => {
manager.authorize('facebook')
.then(resp => Alert.alert('response!' + resp))
.catch(err => Alert.alert('error msg here: ' + err));
}
我猜测这个未定义的错误与 RCTBridge 错误有关,但不确定。您可以在下面看到我何时提醒manager.authorize
发现了错误。TypeError: undefined is not an object (evaluating 'fn')
:
Edit:
When I try to Alert the config
object, I get an error about not being able to stringify it's sub-object.
在 chrome 调试器中查看控制台时,我得到“无法读取未定义的属性‘configureProvider’”并且configureProvider()
是什么react-native-oauth
使用所以看起来管理器设置不正确所以也许我没有很好地链接库。已检查链接是否有效。
Im digging into the errors a bit and it seems like a promise/callback related problem from NativeModules.OAuthManager
. The error caught is: TypeError: Cannot read property 'authorize' of undefined
. When I jump into the stack trace I find:
非常感谢任何帮助,谢谢。