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.