在ios 10.2中永远不会调用didUpdatePushCredentials

时间:2017-06-13 15:42:32

标签: ios objective-c voip ios10.2

所以我打电话给:

self.pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];

它适用于ios 9,10.0.2和10.3。 didUpdatePushCredentials被调用,一切正常。但是对于ios 10.2,从不调用它,整个voip功能都不起作用。你能告诉我它有什么问题吗?

PS:已设置IP语音和远程通知功能。

1 个答案:

答案 0 :(得分:0)

请参阅ObjectiveC代码以进行pushkit集成

<强> AppDelegate.h

#import <UIKit/UIKit.h>
#import <PushKit/PushKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate,PKPushRegistryDelegate>
{
    PKPushRegistry *pushRegistry;
}

@property (strong, nonatomic) UIWindow *window;

@end

<强> AppDelegate.m

#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

Code for ObjectiveC

Reference