title: React Native Possible Unhandled Promise Rejections Error
body: <p>I'm using Agora to send a message through a data stream, it throws this error when I try to do so after changing to another channel (so from channel 1 and 2). Can anyone please help explain what this error means and how to solve it? I've been googling and I couldn't seem to find anything. Thanks a bunch!</p>
  <pre><code>Error: invalid argument
  promiseMethodWrapper@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:2275:45
  sendStreamMessage@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:99747:47
  http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:98393:35
  onPress@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:98579:46
  onPress@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:68941:35
  _performTransitionSideEffects@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:54979:22
  _receiveSignal@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:54921:45
  onResponderRelease@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:54830:34
  invokeGuardedCallbackImpl@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:12804:21
  invokeGuardedCallback@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:12898:42
  invokeGuardedCallbackAndCatchFirstError@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:12902:36
  executeDispatch@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:12974:48
  executeDispatchesInOrder@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:12994:26
  executeDispatchesAndRelease@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:14069:35
  forEach@[native code]
  forEachAccumulated@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:13136:22
  runEventsInBatch@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:14093:27
  runExtractedPluginEventsInBatch@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:14172:25
  http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:14148:42
  batchedUpdates$1@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:24797:20
  batchedUpdates@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:14055:36
  _receiveRootNodeIDEvent@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:14147:23
  receiveTouches@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:14200:34
  __callFunction@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:2798:36
  http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:2530:31
  __guard@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:2752:15
  callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=ios&amp;dev=true&amp;minify=false:2529:21
  callFunctionReturnFlushedQueue@[native code]
  </code></pre>
  <p>Edit:
  Class</p>
  <pre><code>  // States for buttons (touchable highlights).
    state = {
      micPressed: false,
      dotMorsePressed: false,
      dashMorsePressed: false,
      channel1Pressed: false,
      channel2Pressed: false,
    };
  
    componentDidMount() {
        SplashScreen.hide();
        this.init()
    }
  
    init = async () =&gt; {
      // Initialize RtcEngine and event listeners.
        engine = await RtcEngine.create('74a529c906e84fe8bfe4a236869b736f');
        try {
            dataStreamId = await engine.createDataStream(true, true);
        } catch(error) {
            console.log(error.message);
        }
        console.log(&quot;dataStream: &quot;, dataStreamId);
        Sound.setCategory('Playback');
        beep = new Sound('beep.wav', Sound.MAIN_BUNDLE, (error) =&gt; {
            if (error) {
                console.log('failed to load the sound', error);
                return;
            }
        })
        engine.addListener('StreamMessage', (uid, streamId, data) =&gt; {
            console.log('stream message was received: ', data, ' from: ', streamId )
            receivedMorse = data;
            console.log(receivedMorse);
            if(receivedMorse == 'dot'){
                beep.setCurrentTime(9.9);
                beep.play();
            } else {
                beep.setCurrentTime(9.7);
                beep.play();
            }
        })
        engine.addListener('StreamMessageError', (uid, streamId, err, missed, cached) =&gt; {
            console.log('StreamMessageError: ', err)
        })
        engine.addListener('JoinChannelSuccess', (channel, uid, elapsed) =&gt; {
            console.log('channel was joined succesfully')
        })
        engine.addListener('LeaveChannel', (channel, uid, elapsed) =&gt; {
            console.log('channel was left succesfully')
        })
        engine.addListener('Warning', (warn) =&gt; {
            console.log('Warning', warn)
        })
        engine.addListener('Error', (err) =&gt; {
            console.log('Error', err)
        })
    }
  </code></pre>
  <p>Functions:</p>
  <pre><code> // Functions.
    micPressedFunc = () =&gt; {
      // Function to enable microphone and mute speaker when mic button is pressed.
      engine.adjustRecordingSignalVolume(100);
      engine.adjustAudioMixingVolume(0);
    };
  
    micReleasedFunc = () =&gt; {
      // Function to mute microphone and enable speaker when mic button is released.
      engine.adjustRecordingSignalVolume(0);
      engine.adjustAudioMixingVolume(100);
    };
  
    dotMorsePressedFunc = () =&gt; {
      // Function to send dot to other users in the channel.
      engine.sendStreamMessage(dataStreamId, 'dot');
      beep.setCurrentTime(9.9);
      beep.play();
    };
  
    dashMorsePressedFunc = () =&gt; {
      // Function to send dash to other users in the channel.
      engine.sendStreamMessage(dataStreamId, 'dash');
      beep.setCurrentTime(9.7);
      beep.play();
    };
  
    channel1PressedFunc = () =&gt; {
      // Function to leave previous channel and join channel 1.
      engine.leaveChannel();
      engine.joinChannel(null, 'walt-channel-1', null, 0);
      engine.adjustRecordingSignalVolume(0);
      engine.adjustAudioMixingVolume(100);
      isConnected = true;
      this.setState({
        channel1Pressed: true,
        channel2Pressed: false,
      });
    };
  
    channel2PressedFunc = () =&gt; {
      // Function to leave previous channel and join channel 2.
      engine.leaveChannel();
      engine.joinChannel(null, 'walt-channel-2', null, 0);
      engine.adjustRecordingSignalVolume(0);
      engine.adjustAudioMixingVolume(100);
      isConnected = true;
      this.setState({
        channel2Pressed: true,
        channel1Pressed: false,
      });
    };
  </code></pre>