title: How to handle socket connection's events when app is in background?
body: <p>I want use the following function even when app is in background?</p>
  
  <pre><code>- (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent
   {
          case NSStreamEventHasBytesAvailable:
          {  NSLog(@"Event:NSStreamEventHasBytesAvailable");
              if (theStream == _inputStream) {
  
                  NSLog(@"NSStreamEventHasBytesAvailable: on Input Stream");
                  uint8_t buffer[1024];
                  int len;
  
                  while ([_inputStream hasBytesAvailable]) {
                      len = [_inputStream read:buffer maxLength:sizeof(buffer)];
                      if (len &gt; 0) {
  
                          NSString *output = [[NSString alloc] initWithBytes:buffer length:len encoding:NSASCIIStringEncoding];
  
                          if (nil != output) {
  
                              NSLog(@"server said: %@", output);
                               // to get local notification I am calling below method.
   [self scheduleNotification];       
                          }
                      }
                  }
              }
              break;
          }
  </code></pre>
  
  <p>The above code is working done in foreGround. I have made all the change given in apple document to the run the app in the background mode- voip.
  What should i write in AppDelegate method?</p>
  
  <pre><code>- (void)applicationDidEnterBackground:(UIApplication *)application
  {
  }
  </code></pre>
  
  <p>How to get the stream:handleEvent called in background?</p>