title: Socket.emit doesn't work with Ionic
body: <p>I am trying to create a socket connection between my ionic application and a socket server that I've built. </p>
  
  <ul>
  <li><p>The socket connection won't work when running the app in iOS simulator using <code>ionic run ios --target="iPhone-6-Plus"</code></p></li>
  <li><p>The socket connection works when serving the app in the browser using <code>ionic serve</code>.</p></li>
  </ul>
  
  <p><strong>My Code</strong></p>
  
  <ul>
  <li>I'm using <a href="https://github.com/btford/angular-socket-io" rel="nofollow noreferrer">btford's socket.io compontent</a></li>
  </ul>
  
  <p>I have a socket service in my app client that connects to my socket server:</p>
  
  <pre><code>.factory('Sockets', function($http, socketFactory){
  
    var myIoSocket = io.connect('localhost:5000');
  
    var mySocket = socketFactory({
      ioSocket: myIoSocket
    });
  
    return mySocket;
  
  })
  </code></pre>
  
  <p>Here is what my client socket request looks like:</p>
  
  <pre><code>angular.module('crewapp.chat', [])
  .controller('ChatController', function($scope, Auth, Sockets, $localStorage){
    $scope.test = 'Chats';
    Sockets.emit('join room', $localStorage.groupname)
  
  });
  </code></pre>
  
  <p>Here is what my socket server (in short) looks like </p>
  
  <pre><code>io.sockets.on('connection', function(socket) {
    socket.on('join room', function(room) {
      socket.room = room;
      socket.join(room);
      console.log(room);
  });
  </code></pre>
  
  <p><strong>What I've Tried</strong></p>
  
  <ol>
  <li>I've tried seeing if Socket.emit is defined in the app which it is:</li>
  </ol>
  
  <p><img src="https://i.stack.imgur.com/EuIme.png" alt="Socket.emit defined in client"></p>
  
  <ol start="2">
  <li>I've generalized where the socket server should log by placing a console.log in <code>socket.on('connection')</code> callback's function body. </li>
  </ol>