didUpdatePushCredentials is never called in ios 10.2

973 Views Asked by At

So I have called:

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

And it works on ios 9, 10.0.2 and 10.3. didUpdatePushCredentials is called and everything is ok. However for ios 10.2 it is never called and whole voip functionality doesn't work. Could you please advise what is wrong with it?

PS: Voice over IP and Remote notifications capabilities are set.

1

There are 1 best solutions below

5
Hasya On

Refer ObjectiveC code for pushkit integration

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