2017-06-26 128 views
0

我剛更新Xcode到版本8.3.3和pushRegistry:didUpdatePushCredentials:forType:不再被調用。didUpdatePushCredentials不再調用[Xcode 8.3.3]

在這個新版本的Xcode中,有沒有和PushKit相關的東西?

這是我註冊代碼:

_voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()]; 
    _voipRegistry.delegate = self; 
    _voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; 

回答

1

還有就是版本的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

希望這可以幫助你。

+0

似乎重新啓動我的mac解決了問題:/ 無論如何,感謝您的幫助。 –