2016-11-17 9 views
0

私のVOIPアプリケーションのバックグラウンドモードを有効にするためにこのコードを使用しています。キープアライブのアプリケーションがバックグラウンドで電話を受けることができません

- (void)applicationDidEnterBackground:(UIApplication *)application{ 

[NSTimer timerWithTimeInterval:60.0 target:self selector:@selector(sipRegisterEveryTime) userInfo:nil repeats:YES]; 
[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES]; 
[application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: 
^{ 
    [self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES]; 
}];} 

、コードは次のとおりです。

- (void)keepAlive{ 
int i; 
if (!pj_thread_is_registered()) 
{ 
    pj_thread_register("ipjsua", a_thread_desc, &a_thread); 
} 
/* Since iOS requires that the minimum keep alive interval is 600s,  * application needs to make sure that the account's registration  
* timeout is long enough.  */ 
for (i = 0; i < (int)pjsua_acc_get_count(); ++i) 
{ 
    if (pjsua_acc_is_valid(i)) 
    { 
     pjsua_acc_set_registration(i, PJ_TRUE); 
    } 
} 
pj_thread_sleep(15000);} 

しかし、私は私のアプリがバックグラウンドで動作している間、任意のVOIPコールが到着している場合は目覚め私のアプリを取得しておりません。 info.plistには、「必要なバックグラウンドモード」内で「AppがVoice over IPサービスを提供する」を設定することで、VOIPバックグラウンドに対して有効な設定があります。VOIPの内部機能設定が完了しました。私がする必要があることは何ですか?私は私のVOIPアプリケーションのPJSIPライブラリを使用しています。あなたのInfo.plistファイル

enter image description here

にこれらの文字列を追加すること

+0

チェックを参照してください。トランスポートはTCPプロトコルを使用している場合、それがバックグラウンドで動作する唯一の一つです。 – azimov

答えて

関連する問題