Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS Voip Socket will not run in background
    primarykey
    data
    text
    <p>I am getting a VOIP socket to run in the background in an iOS application.</p> <p>My connection works fine, but it won't wake up when my app goes into the background. If I open the app back up, though, it responds to any messages it got while it was asleep.</p> <p>I set up my stream like this:</p> <pre><code>CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (CFStringRef) @"test.iusealocaltestserver.com", 5060, &amp;myReadStream, &amp;myWriteStream); CFReadStreamSetProperty ( myReadStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP ); CFSocketNativeHandle native; CFDataRef nativeProp = CFReadStreamCopyProperty(myReadStream, kCFStreamPropertySocketNativeHandle); CFDataGetBytes(nativeProp, CFRangeMake(0, CFDataGetLength(nativeProp)), (UInt8 *)&amp;native); CFRelease(nativeProp); CFSocketRef theSocket = CFSocketCreateWithNative(kCFAllocatorDefault, native, 0, NULL, NULL); CFSocketGetContext(theSocket,&amp;theContext); CFOptionFlags readStreamEvents = kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered | kCFStreamEventOpenCompleted; CFReadStreamSetClient(myReadStream, readStreamEvents, (CFReadStreamClientCallBack)&amp;MyCFReadStreamCallback, (CFStreamClientContext *)(&amp;theContext)); CFReadStreamScheduleWithRunLoop(myReadStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes); </code></pre> <p>Then my callback is set up like this:</p> <pre><code>static void MyCFReadStreamCallback(CFReadStreamRef stream, CFStreamEventType type, void *pInfo); static void MyCFReadStreamCallback (CFReadStreamRef stream, CFStreamEventType type, void *pInfo) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog(@"Callback Happened"); [pool release]; } </code></pre> <p>"Callback Happened" is getting called when I receive data and the app is open, but it doesn't if the app is minimized. When the app comes back up, though, it processes any data it received while minimized. </p> <p>I added the voip tag to the info.plist. My CFReadStreamSetProperty returns true. I am running on a device not a simulator. It still doesn't work though, so I dont know what my problem could be. I probably just did something silly, but there's almost nothing online to check my code against.</p> <p>EDIT: I can't test any of the answers because I am no longer working on this project and don't have access to a mac/iOs sdk. If someone with a similar problem found one of the below answers useful, let me know and I will vote it best answer.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload