2017-06-01 13 views
2

私のVoipアプリはバックグラウンドモードで使用していますが、バックグラウンドモードになると私のVoIPアプリケーションが起動します。到着すると、通知が表示されます。私はIOS 8以降でそれを見たsetKeepAliveTimeoutはもう働かないと私たちはプッシュキットを使用する必要があります、とにかく私たちのサーバー側をコーディングせずにpushKitを使用するには?先に行くVoip Appのバックグラウンドを使用する方法

- (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]; 
    }]; 

} 

答えて

0

また、着信を知り、さらに処理を行うためにアプリを強制終了状態にしたい場合は、プッシュキットのサイレント通知で作業する必要があります。 (この方法のWhatsApp通話、スカイプなどのアプリの作品)

Refer

#import "AppDelegate.h" 

@interface AppDelegate() 

@end 

@implementation AppDelegate 


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 


    pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()]; 
    pushRegistry.delegate = self; 
    pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; 

    return YES; 
} 

#define PushKit Delegate Methods 

- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type{ 
    if([credentials.token length] == 0) { 
     NSLog(@"voip token NULL"); 
     return; 
    } 

    NSLog(@"PushCredentials: %@", credentials.token); 
} 

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type 
{ 
    NSLog(@"didReceiveIncomingPushWithPayload"); 
} 


@end 

Way to schedule local notification based on puskit payload

+0

こんにちは@ハシャ、ありがとうございます。上記の関数をNSLog(@ "didReceiveIncomingPushWithPayload")の代わりに使用したい場合は、私は何を使う必要があるか考えていますか?この方法ではうまくいかないからです。 – Steven

+0

歓迎@スティーブン、私の答えがあなたを助けたならば、それをアップヴォートして受け入れることができます。私がいつでもあなたを助けることができるかどうか教えてください。 – Hasya

+0

Pushkitペイロードを受け取ることができますか?はいの場合はプッシュキットペイロードに基づいて、着信音でローカル通知をスケジュールできます。また、対話的なイベントを追加してcall.https://github.com/hasyapanchasara/PushKit_SilentPushNotification/issues/1を受け入れるか拒否することができます – Hasya

0

、iOSの11に全面的にIP電話BGソケットを非推奨になるだろうとのiOSでバックグラウンド(BG)は、VoIPアプリケーションのためのPushkitを使用してその義務(私はすでに、彼らがiOSの10 SDKでサポートを廃止予定していると思いますしかし、iOS 10はSDK 9で動作します)

あなたの質問に答えるには、AppleのAPNSクラウドと話すために、サーバー側でAPNSインターフェイスを実装して、アプリケーションがAppleを通じてVoip CallなどのVOIPプッシュを受信できるようにする必要があります。また、BGNのVOIPアプリは、プッシュキットを使用しているアプリにVoip Pushesを配信するためにAPNSインターフェイスが必須であるため、クローズドネットワーク(インターネットなし)にいるiOSでは機能しません。

+0

こんにちは@Ayush、私は、サーバー側にAPNSインターフェイスを実装する方法の任意のチュートリアルを見つけることができませんアップルのAPNSクラウドと話をする。とにかくそれを行う方法をいくつかのチュートリアルを見つけるためにはありますか? – Steven

+0

それは少し変です。 Appleは実際に同じ文書を完全に提供している。 https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1 – Ayush

関連する問題