how to use pushkit with background in Voip App

Viewed 4323

Curently for my Voip App in background mode I use the code bellow, that keeps my voip App awake when it goes in background or when It goes in background and lock the phone when the call arrive, it shows the notification. I saw that in IOS 8 and later setKeepAliveTimeout not work anymore and we need to use Pushkit, is there anyway to use pushKit without coding our server side?

- (void)registerKeepAliveHandler:(UIApplication*) application
{
    LogInfo(TAG_MAIN, @"Registering KeepAliveTimeout");
    [application setKeepAliveTimeout:600 handler:^{
        [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_KEEPALIVE_RECEIVED object:nil];
        NSMutableString* statusStr = [[NSMutableString alloc] init];
        switch ([[UIApplication sharedApplication] applicationState]) {
            case UIApplicationStateActive:
                [statusStr appendString:@"foreground"];
                break;
            case UIApplicationStateInactive:
                [statusStr appendString:@"inactive"];
                break;
            case UIApplicationStateBackground:
                [statusStr appendString:@"background"];
                break;
            default:
                assert(0);
                break;
        }
        LogInfo(TAG_MAIN, @"===================================== Keepalive received in %@ application status ===============================", statusStr);
        [UIApplication getIPAddress];
        LogInfo(TAG_MAIN, @"%@", [[UIDevice currentDevice] batteryInfo]);
        [[SipEngine sharedInstance] isServerReachable];
        [[SipEngine sharedInstance] isRegistered];
        [[SipEngine sharedInstance] startStopRegistration];
        [[[SipEngine sharedInstance] registration] registering];
    }];

}
2 Answers
Related