2014-09-04 56 views
0

我正在使用PJSIP開發iPhone應用程序。當我進入後臺模式時,如果我收到任何電話。 我顯示UILocalNotification警覺:在iOS中顯示UILocalNOtification提醒VOIP電話有效

UILocalNotification *notification = [[UILocalNotification alloc] init]; 

NSString *alertBody = [NSString stringWithFormat:@"NEW VOIP CALL"]; 
notification.alertBody =alertBody; 
notification.alertAction = @"Answer"; 
[[UIApplication sharedApplication] presentLocalNotificationNow:notification]; 

但是,一些4或5秒鐘後,這個警報解僱。 如何讓它重複一段時間?

回答

0

解決方案1:您需要使用計時器執行UIlaocationNotification。

解決方案2:您在完成上次通知時開始執行通知。

+0

嘿炳廷,像這樣????好像評論不更新完全 – sambhav 2014-09-04 05:54:55

+0

我的觀點是一旦第一個警報再次完成你產生新的alert.Once單擊查看按鈕,您可以停止所有警報全部 – PREMKUMAR 2014-09-04 05:56:49

+0

正如您在解決方案2中所述 - >在完成上一次時開始執行通知。那麼是否有任何委託方法或一些通知會告訴我之前的通知已經完成...您能否用一些小代碼演示來解釋 – sambhav 2014-09-04 09:01:25

0

在您的情況下,最好的方法是指定要播放的聲音 - 這可以長達30秒。這似乎保持了聲音的長度所顯示的通知:

UILocalNotification *notification =[[UILocalNotification alloc] init]; 
NSString *alertBody = [NSString stringWithFormat:@"NEW VOIP CALL"]; 
notification.alertBody =alertBody; 
notification.alertAction = @"Answer"; 
notification.soundName = @"56 Alarm Bell.mp3"; 
[[UIApplication sharedApplication] presentLocalNotificationNow:notification]; 
+0

但是,這隻會使當時的聲音,而不是警報。 我在SKYPE中看到它已經實現,但不知道如何 – sambhav 2014-09-04 05:54:12