ios - 不再调用 didUpdatePushCredentials [Xcode 8.3.3]

标签 ios xcode pushkit

我刚刚将 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 没有变化。从 2.2 到 3.X,swift 语言的语法级别发生了变化,但 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

希望对你有帮助。

关于ios - 不再调用 didUpdatePushCredentials [Xcode 8.3.3],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44769235/

相关文章:

iOS VoIP 服务证书

javascript - iOS UIWebView 中未定义 requestAnimationFrame?

objective-c - 预期的说明符限定符列表 - 为什么?

ios - React Native 0.60.5 中未链接模块

c++ - <string.h> 与我自己的 String.h 冲突

push-notification - 我可以在不使用 VoIP 的情况下将 PushKit 用于标准推送通知吗?应用程序在审查中被拒绝的可能性有多大?

c# - 如何将数据从 PC 发送到手机 c#

iphone - "Swanky and Moo Moo"字体在 ios 中不起作用

ios - Swift3 错误 : Type 'NSFastEnumerationIterator.Element' (aka 'Any' ) does not conform to protocol 'AnyObject'