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

  • Home
  • SEARCH
  • 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 6882895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:18:44+00:00 2026-05-27T05:18:44+00:00

My application is primarily a client for a server that really doesn’t have a

  • 0

My application is primarily a client for a server that really doesn’t have a connection to the internet. It connects to a Polycom codec and manages the video calls between 2 endpoints. So my application can send commands like end call, volume up, etc…
However my problem is this. I need some kind of notification when an incoming call happens and the application is not in the foreground.
Since the server does not have internet access APNS/push notifications will not work for me. I have looked into doing something like this. Which does seem to keep my client running however I cannot do an alert since my application is in the background.

So besides the basics of how to fix my problem my questions are:

Can I bring my application to the foreground using the technique listed in the link (doing something like what I’m doing below). I can see from the logs that this code keeps my code running. I know my while loop is not right and in the end I would need KVO but regardless that shouldn’t effect the answer. (one thing I dont understand is this keeps my whole application running as opposed to just the class I have in there bcClient?)

- (void)applicationDidEnterBackground:(UIApplication *)application
{    
     [bcClient connect];
     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(3);
               NSLog(@"held join %d",bcClient.heldjoin);

               if (bcClient.heldjoin == 602 || bcClient.heldjoin == 604 || bcClient.heldjoin == 513) {
                    NSLog(@"incoming call");
               }
          }   
     });           
}

If I cannot bring my application to the foreground then is there anyways to push a notification locally (without the need for a APNS server)?

I have a feeling none of this is possible but I figured I would ask.

  • 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-27T05:18:45+00:00Added an answer on May 27, 2026 at 5:18 am

    Here is my answer. This keeps my client application running in the background and shows a notification when a call comes in.

    AppDelegate.h

    @interface CameleonAppDelegate : NSObject <UIApplicationDelegate> {
    
        CrestronClient *cClient;
        CrestronControllerValues *CCV;
        RootViewController *rootViewController;
        CrestronValues *crestronValues;
    
        UIBackgroundTaskIdentifier bgTask;
        dispatch_block_t expirationHandler;
        UIApplication*    app;
        BOOL showedCall;
    }
    @property (nonatomic, retain) IBOutlet UIWindow *window;
    
    @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
    @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
    @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
    
    - (void)saveContext;
    - (NSURL *)applicationDocumentsDirectory;
    -(void)save;
    -(void)load;
    - (void)backgroundHandler;
    @end
    

    AppDelegate.m (just didFinishLaunchingWithOptions and applicationDidEnterBackground)

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {    
         app = [UIApplication sharedApplication];
         expirationHandler = ^{
    
              [app endBackgroundTask:bgTask];
              bgTask = UIBackgroundTaskInvalid;
    
    
              bgTask = [app beginBackgroundTaskWithExpirationHandler:expirationHandler];
         };
    
    
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    
        NSArray *keys = [NSArray arrayWithObjects:@"IPaddress", @"PortNumber",@"IPID", nil];
    
        NSArray *objs = [NSArray arrayWithObjects:@"10.8.40.64", @"41794",@"3", nil];
    
        //10.8.30.143       10.8.40.64
    
        NSDictionary *dict = [NSDictionary dictionaryWithObjects:objs forKeys:keys];
    
        [defaults registerDefaults:dict];
    
         CCV = [CrestronControllerValues sharedManager];
    
        [CCV setIpAddress:[defaults stringForKey:@"IPaddress"]];
        [CCV setPortNumber:[defaults stringForKey:@"PortNumber"]];
        [CCV setIPID:[defaults stringForKey:@"IPID"]];
    
    
        cClient = [CrestronClient sharedManager];
    
    
         rootViewController = [[RootViewController alloc]initWithNibName:@"RootViewController" bundle:nil];
         self.window.rootViewController = rootViewController;
         [self.window makeKeyAndVisible];   
    
        return YES;
    }
    
    
    - (void)applicationDidEnterBackground:(UIApplication *)application
    {
         showedCall = FALSE;
         BOOL backgroundAccepted = [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ [self backgroundHandler]; }];
         if (backgroundAccepted)
         {
              NSLog(@"VOIP backgrounding accepted");
         }
    
    
         bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
              [app endBackgroundTask:bgTask];
              bgTask = UIBackgroundTaskInvalid;
         }];
    
    
         // Start the long-running task
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    
              while (1) {
                   sleep(4);
                   //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;
                   }
              }
         });           
    }
    - (void)backgroundHandler {
    
         NSLog(@"### -->VOIP backgrounding callback");
    
    
         bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
              [app endBackgroundTask:bgTask];
              bgTask = UIBackgroundTaskInvalid;
         }];
    
         // Start the long-running task 
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    
              while (1) {
                   NSLog(@"BGTime left: %f", [UIApplication sharedApplication].backgroundTimeRemaining);
                   [rootViewController isIncomingCall];
                   sleep(1);
              }   
         });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So my web application is primarily using XML for client to server interaction and
I have a web application with a great deal of both client-side and server-side
I'm writing a client/server application that requires the server needs to be able to
I have a C# form application that connects to a electronic device using the
I'm planning a web app that is exposed primarily through a client application through
I have an application that has a primary layout of portrait (it is fixed
I have a fairly complex business application written in ASP.NET that is deployed on
For my client side development I use MooTools primarily, I have also just recently
we have 2 DataTables in a .NET application having a Client / Parent relationship
We have an XMPP application that uses MySQL to store information. We are not

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.