首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >didUpdatePushCredentials从未在IOS10.2中被调用

didUpdatePushCredentials从未在IOS10.2中被调用
EN

Stack Overflow用户
提问于 2017-06-13 15:42:32
回答 1查看 941关注 0票数 0

所以我打电话说:

self.pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];

它适用于ios 9、10.0.2和10.3。didUpdatePushCredentials被调用,一切都很好。然而,对于IOS10.2来说,它从来没有被调用过,而且整个voip功能都无法工作。你能告诉我它有什么问题吗?

PS:设置了IP语音和远程通知功能。

EN

回答 1

Stack Overflow用户

发布于 2017-06-19 09:19:23

参考ObjectiveC代码进行推包集成

AppDelegate.h

代码语言:javascript
复制
#import <UIKit/UIKit.h>
#import <PushKit/PushKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate,PKPushRegistryDelegate>
{
    PKPushRegistry *pushRegistry;
}

@property (strong, nonatomic) UIWindow *window;

@end

AppDelegate.m

代码语言:javascript
复制
#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

ObjectiveC代码

参考文献

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44526040

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档