還有就是版本的Xcode 8.3.3與pushkit沒有變化。語法級別從2.2到3.X的語言級別變化,但Objective C沒有任何變化(我看到你的代碼在Objective 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");
}
Refer
希望這可以幫助你。
似乎重新啓動我的mac解決了問題:/ 無論如何,感謝您的幫助。 –