0
우리 앱에서 앱을 배경으로 푸시하면 사용자 등록을 취소해야합니다. PJSIP을 사용하고 있습니다. 내 applicationDidEnterBackground :와 :PJSIP를 사용한 SIP 등록 취소
- (void)applicationDidEnterBackground:(UIApplication *)application {
NSLog(@"did enter background");
__block UIBackgroundTaskIdentifier bgTask;
bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self deregis];
[application endBackgroundTask: bgTask]; //End the task so the system knows that you are done with what you need to perform
bgTask = UIBackgroundTaskInvalid; //Invalidate the background_task
NSLog(@"\n\nRunning in the background!\n\n");
});
}
deregis 방법은 다음과 같습니다 :
- (void)deregis {
if (!pj_thread_is_registered())
{
pj_thread_register("ipjsua", a_thread_desc, &a_thread);
}
dereg();
}
그리고 드 - 등록 방법은 다음과 같습니다 :
void dereg()
{
int i;
for (i=0; i<(int)pjsua_acc_get_count(); ++i) {
if (!pjsua_acc_is_valid(i))
pjsua_buddy_del(i);
pjsua_acc_set_registration(i, PJ_FALSE);
}
}
우리는 배경에 응용 프로그램을 누르면, dereg가 호출됩니다. 그러나 서버가 401 챌린지를 다시 보내면 응용 프로그램을 다시 포 그라운드로 가져올 때까지 스택이 SIP 통화의 인증 세부 정보를 다시 보내지 않습니다. 왜 이런 일이 일어나는 지 아는 사람이 있습니까?
감사합니다, Hetal