0

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.

Artem Bakanov
  • 250
  • 2
  • 12

1 Answers1

0

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

Hasya
  • 9,792
  • 4
  • 31
  • 46
  • Does it worked for you? if yes then you can accept answer. – Hasya Jun 28 '17 at 12:03
  • Not really. As I mentioned above, in my case notifications are not working only in iOs 10.2. Do you have some ios 10.2 specific lines of code? Could you please refer to them if yes? – Artem Bakanov Jul 03 '17 at 12:23
  • With Pushkit, there is nothing specific with iOS 10.2, i suggest once cross verify your code with https://github.com/hasyapanchasara/PushKit_SilentPushNotification – Hasya Jul 03 '17 at 12:43
  • Thank you. Yes, my code is pretty similar to yours. However, still doesn't work with iOs 10.2 only. Seems that there is some issue there. – Artem Bakanov Jul 04 '17 at 10:00
  • Have you downloaded my code and sent Pushkit payload as per PHP file in iOS 10.2, if this is working then something wrong in your code then you can rewrite your code as per mine, also you can check is your app crashing in terminated mode, i have written something for that as well on https://github.com/hasyapanchasara/PushKit_SilentPushNotification – Hasya Jul 04 '17 at 10:09