Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7048951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:57:13+00:00 2026-05-28T02:57:13+00:00

I’m trying to implement this (Configuring Sockets for VoIP Usage) using this (CocoaAsyncSocket). To

  • 0

I’m trying to implement this(Configuring Sockets for VoIP Usage) using this(CocoaAsyncSocket). To the best of my knowledge step 1 I have done, adding VOIP to background services in the plist, and below should be step 2 (Configure one of the app’s sockets for VoIP usage)

- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)connectedPort
{
    [CCV setLocalMode:FALSE];

    [socket performBlock:^{
                 [socket enableBackgroundingOnSocket];
             }];

But the rest of the steps I cannot figure out.
If I do

- (void)applicationDidEnterBackground:(UIApplication *)application
{
     expirationHandler = ^{

          [app endBackgroundTask:bgTask];
          bgTask = UIBackgroundTaskInvalid;


          bgTask = [app beginBackgroundTaskWithExpirationHandler:expirationHandler];
     };

     bgTask = [app beginBackgroundTaskWithExpirationHandler:expirationHandler];


     // Start the long-running task and return immediately.
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

          while (1) {
               sleep(1);               
               //NSLog(@"BGTime left: %f", [UIApplication sharedApplication].backgroundTimeRemaining);

               if ([rootViewController isIncomingCall] && showedCall != TRUE) {
                    UILocalNotification *localNotif = [[UILocalNotification alloc] init];
                    if (localNotif) {
                         localNotif.alertBody = [NSString stringWithFormat:@"Incoming Call."];
                         localNotif.alertAction = NSLocalizedString(@"Accept Call", nil);
                         localNotif.soundName = @"alarmsound.caf";
                         //                         localNotif.applicationIconBadgeNumber = 1;
                         [application presentLocalNotificationNow:localNotif];
                         [localNotif release];
                    }
                    showedCall = TRUE;
               }
          }  
     });      

}

My client will listen for 10mins then stop. I need to do 2 things: watch for a specific (incoming call) data packet, and send a keepalive every 5seconds. But I dont see where these things are to be configured at. Furthermore the definition on the apple link above states “To prevent the loss of its connection, a VoIP app typically needs to wake up periodically and check in with its server. To facilitate this behavior, iOS lets you install a special handler using the setKeepAliveTimeout:handler: method of UIApplication“ From my understanding of that this timeout thing should only be doing the keepalive, however that doesnt make sense because the minimal time is 600seconds? And like I said above I cannot find where I tell it what packet to look for as well as what to do when its found.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:57:13+00:00Added an answer on May 28, 2026 at 2:57 am

    so i believe i have resolved the issue but need further testing to be 100% sure. Currently i ran a test with this code for the length of 21mins of suspended time and it worked

    step 2:

     [socket performBlock:^{
                     [socket enableBackgroundingOnSocket];
                 }];
    

    step 3:

    - (void)applicationDidEnterBackground:(UIApplication *)application {
    
         inProgram = FALSE;
         showedCall = FALSE;
    
         BOOL backgroundAccepted = [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ [self backgroundHandler]; }];
         if (backgroundAccepted)
         {
              NSLog(@"VOIP backgrounding accepted");
         }
    
    }
    

    this seems to keep my client running so from here i add an observer to wait for my incoming call packet and launch a notification when that packet is seen

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
    {  
         if ([keyPath isEqualToString:@"currentDigitalJoin"]) 
         {
              switch ([[cClient currentDigitalJoin]intValue]) 
              {  
                   case 1000: 
                   {   
                        if (showedCall != TRUE && inProgram != TRUE) {
                             NSLog(@"incoming audio call");
                             UILocalNotification *localNotif = [[UILocalNotification alloc] init];
                             if (localNotif) {
                                  localNotif.alertBody = [NSString stringWithFormat:@"Incoming Call."];
                                  localNotif.alertAction = NSLocalizedString(@"Accept Call", nil);
                                  localNotif.soundName = @"alarmsound.caf";
                                  [app presentLocalNotificationNow:localNotif];
                                  [localNotif release];
                                  showedCall = TRUE;
                             }
                        }
                        break;
                   }
                   case 602: 
                   {   
                        if (showedCall != TRUE && inProgram != TRUE) {
                             NSLog(@"incoming audio call");
                             UILocalNotification *localNotif = [[UILocalNotification alloc] init];
                             if (localNotif) {
                                  localNotif.alertBody = [NSString stringWithFormat:@"Incoming Call."];
                                  localNotif.alertAction = NSLocalizedString(@"Accept Call", nil);
                                  localNotif.soundName = @"alarmsound.caf";
                                  [app presentLocalNotificationNow:localNotif];
                                  [localNotif release];
                                  showedCall = TRUE;
                             }
                        }
                        break;
                   }
                   case 513: 
                   {   
                        showedCall = FALSE;
                        break;
                   }
              }
         }else if([keyPath isEqualToString:@"currentDigitalJoin"])
         {
              switch ([[cClient currentDigitalJoin]intValue]) 
              { 
                   case 602: 
                   {   
                        showedCall = FALSE;
                        break;
    
                   }               
              }
         }
    }
    

    NOTE: the “step”s indicated are in reference to the steps indicated on the apple documentation

    also dont forget to set the require wireless in the plist file

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.