RCTBatchedBridge.m Error: Invalid data message - all must be length:%zd. React Native, iOS simulator
<p>I'm using <code>react-native-oauth</code> and getting this error (see red image at bottom) when trying to authorise. I've searched and found only this <a href="https://stackoverflow.com/questions/40905638/error-invalid-data-message-all-must-be-length-8-pickerios">similar unanswered question</a>. I looked into the source and found <a href="https://github.com/facebook/react-native/blob/master/React/Base/RCTBatchedBridge.m" rel="nofollow noreferrer">where the error is raised</a> on line 954 and it seems it's because <code>moduleIDs.count</code> should equal <code>methodIDs.count</code> and <code>paramsArrays.count</code> :</p>

<pre><code>  if (RCT_DEBUG &amp;&amp; (moduleIDs.count != methodIDs.count || moduleIDs.count != paramsArrays.count)) {
RCTLogError(@"Invalid data message - all must be length: %zd", moduleIDs.count);
</code></pre>

<p>So, still in <a href="https://github.com/facebook/react-native/blob/master/React/Base/RCTBatchedBridge.m" rel="nofollow noreferrer">the source</a>, I look for these objects and find them defined just above, on lines 943-945 and they are using RCTConvert, whose functions "...all accept a JSON value as input and map it to a native Objective-C type or class." <a href="https://facebook.github.io/react-native/docs/native-modules-ios.html" rel="nofollow noreferrer">- React's docs</a></p>

<p>So it seems like this is a transpiling and/or networking related error. But I have basically 0 knowledge on those fields and feel I've hit a barrier to investigating and wondered if anybody had any ideas on moving forward. Being new to React Native and never having done any Objective-C can't be helping me.</p>

<p>Also, here's my code generating the errors. </p>

<pre><code>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 = () =&gt; {
   manager.authorize('facebook')
     .then(resp =&gt; Alert.alert('response!' + resp))
     .catch(err =&gt; Alert.alert('error msg here: ' + err));
}
</code></pre>

<p>I am guessing this undefined error is related to the RCTBridge error but not sure. You can below see when I Alert the <code>manager.authorize</code>'s caught error. <code>TypeError: undefined is not an object (evaluating 'fn')</code>: </p>

<p><a href="https://i.stack.imgur.com/qLpufm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qLpufm.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/ILCtqm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ILCtqm.png" alt="this error"></a></p>

<p>Edit: </p>

<p>When I try to Alert the <code>config</code> object, I get an error about not being able to stringify it's sub-object. <a href="https://i.stack.imgur.com/piPtGm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/piPtGm.png" alt="enter image description here"></a></p>

<p>When looking in console in chrome debugger, I get "Cannot read property 'configureProvider' of undefined" and <code>configureProvider()</code> is what <code>react-native-oauth</code> uses so it looks like the manager is not set up right so maybe I didn't link the library well. Have checked the linking worked.</p>

<p>Im digging into the errors a bit and it seems like a promise/callback related problem from <code>NativeModules.OAuthManager</code>. The error caught is: <code>TypeError: Cannot read property 'authorize' of undefined</code>. When I jump into the stack trace I find: <a href="https://i.stack.imgur.com/K699V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K699V.png" alt="enter image description here"></a> </p>

<p>Any help is much appreciated, thanks.</p>