当应用程序终止且手机被锁定时,VOIP推送代理不会被呼叫

时间:2017-03-01 06:13:44

标签: ios objective-c voip callkit pushkit

我正在使用VOIP应用程序,当应用程序处于前台或后台时我收到了voip push但是当应用程序终止或强制退出时 并且iPhone进入锁定模式...设备获取voip push(我在设备控制台中检查)

Received message for enabled topic 'com.kipl.app.voip' with payload '{
    aps =     {
        alert = "Misscall from +91 9782260101";
        "content-available" = 1;
        sound = default;
    };
    "message_data" =     {
        UUID = "E740A875-65B2-4E4C-AF3C-3B886AA040F3";
        handle = 919782260101;
        hasVideo = 0;
        image = "201702/589c6c27febed30d03c32f54.jpg";
        message = "Misscall from +91 9782260101";
        phone = "+91 9782260101";
        pushType = miscall;
        username = "";
    };
}' onInterface: NonCellular  for device token: NO  with priority (null)
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSMessageStore: 0x10035adb0> asked to store incoming message <APSIncomingMessage: 0x1003a1f00> with guid B0C02302-772D-423B-A525-A0115F98DA29 environment <APSEnvironment: 0x10030f610: production>
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSCourier: 0x100311180>: Calling into AWD for PushReceived
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSCourier: 0x100311180>: AWD for PushReceived finished
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSCourier: 0x100311180>: Stream processing: complete no, invalid no, length parsed 0, parameters (null)
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: APSMessageStore - New message record [<APSIncomingMessageRecord 0x1004d7540 [0x1ac0d6bb8]>{}] has ID [1400].
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSMessageStore: 0x10035adb0> calling completion block for incoming message B0C02302-772D-423B-A525-A0115F98DA29
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSCourier: 0x100311180>: Sending acknowledgement message with response 0 and messageId <04000000> (4)
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSCourier: 0x100311180> Noting push - using last lq 0 and rat (null)  (instead of -2, kCTRegistrationRadioAccessTechnologyUnknown)
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSDecayTimer: 0x1004127f0>:APSNetworkMonitor decaying cost (381 - 6) = 375 for 24.425812 seconds
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSDecayTimer: 0x1004127f0>:APSNetworkMonitor addCost: 166 - _currentCost is now 541
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: <APSCourier: 0x100311180> _notifyForIncomingMessage <APSIncomingMessage: 0x1003a1f00> with guid B0C02302-772D-423B-A525-A0115F98DA29
Mar  4 12:52:14 iPhone apsd(PersistentConnection)[86] <Notice>: 2017-03-04 12:52:14 +0530 apsd[86]: Dispatching high priority message: <OS_xpc_dictionary: <dictionary: 0x1003ed2a0> { count = 2, transaction: 0, voucher = 0x0, contents =
    "message" => <dictionary: 0x10038a050> { count = 1, transaction: 0, voucher = 0x0, contents =
        "ECF19A18-7AA6-4141-B4DC-A2E5123B2B5C" => <data: 0x1003a8360>: { length = 16384 bytes, contents = 0x62706c6973743135137e020000000000801200000000d87f... }
    }
    "message-type" => <int64: 0x10035c950>: 30
}>

同时didFinishLaunchingWithOptions已调用,但 pushkit 委托不会调用。此外,我正在使用呼叫套件接听来电。

1)当app for forground ... push work

2)应用程序从后台删除并锁定手机...在设备中按下接收但是pushkit委托没有调用..问题

有人可以建议,我该如何克服这个问题?

1 个答案:

答案 0 :(得分:0)

您也可以逐步参考整个pushkit流程。

Swift和Objective C代码也在那里。

https://github.com/hasyapanchasara/PushKit_SilentPushNotification

请参阅下面的AppDelegate中的pushkit委托代码。

#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");
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

希望这会对你有所帮助。

一切顺利。

以终止状态调试pudhkit委托。

将调试指针放在委托方法上,转到编辑方案,选择运行选项然后启动 - &gt;等待可执行文件启动。从后端发送推送工具包有效负载,一旦你在设备上获得有效负载,它将自动调用并调试指针将在委托方法中调用。

enter image description here