4

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

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)当应用程序在前台时......推送工作

2)应用程序从后台删除并锁定手机......在设备中推送接收但pushkit代表不调用..问题

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

4

1 回答 1

-1

您也可以逐步参考整个 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 委托。

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

在此处输入图像描述

于 2017-03-01T12:53:27.657 回答