我刚刚将xcode更新为版本8.3.3,而 pushRegistry:didUpdatePushCredentials:forType:
不再被调用。
在此新版本的Xcode中与PushKit相关的事物发生了变化?
这是我注册的代码:
_voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
_voipRegistry.delegate = self;
_voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
使用PushKit对Xcode版本8.3.3没有更改。Swift语言从2.2到3.x有语法级别的变化,但是目标C。(我看到您的代码在目标C中(
(我建议一旦您可以跨验证您的代码。
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");
}
参考
希望这对您有帮助。