0
votes

I am badly in need of a background task to run always, when application is in background.

It is needed for a voip application. All steps are done for voip app.

I am using following script to run background task

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    UIApplication *app = [UIApplication sharedApplication];
    UIBackgroundTaskIdentifier bgTask;
    self.bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:self.bgTask];
    }];
}

After using it, when application goes to background, within 10 minutes if a sip call comes UILocalnotification appear. but after 10 minutes if a sip call comes UILocalnotification did not appear.

Please anybody help me.

2

2 Answers

1
votes

Have you added voip as a background mode to the UIBackgroundModes key in your application Info.plist file?

0
votes

There may be a possibility that your app is crashing because of many requests in background.I hope that you already followed these steps:

There are several requirements for implementing a VoIP app:

  • Add the UIBackgroundModes key to your app’s Info.plist file. Set the value of this key to an array that includes the voip string.

    • Configure one of the app’s sockets for VoIP usage.

    • Before moving to the background, call the

    • setKeepAliveTimeout:handler: method to install a handler to be
    • executed periodically. Your app can use this handler to maintain its service connection.

    • Configure your audio session to handle transitions to and from active use.

    To ensure a better user experience on iPhone, use the Core Telephony framework to adjust your behavior in relation to cell-based phone calls; see Core Telephony Framework Reference.

  • To ensure good performance for your VoIP app, use the System Configuration framework to detect network changes and allow your app to sleep as much as possible.