didUpdatePushCredentials没有被调用 [英] didUpdatePushCredentials not get called
本文介绍了didUpdatePushCredentials没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的iOS应用程序中实现VoIP通知,但是 didUpdatePushCredentials 方法从未调用过,我无法获得设备令牌.
I want to implement VoIP notifications in my iOS application, But the didUpdatePushCredentials method never got called, I can't get the device token.
我已经在应用程序中实现了APNS,这两个服务可能会冲突吗?
I had implemented APNS in the application, May these two services conflict ?
这是我的AppDelegate代码
Here is my AppDelegate codes
- (void)application:(UIApplication *)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
LOGI(@"%@", NSStringFromSelector(_cmd));
//register for voip notifications
self->pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
[self->pushRegistry setDelegate:self];
[self->pushRegistry setDesiredPushTypes:[NSSet setWithObject:PKPushTypeVoIP]];
NSLog(@"VoIP push registered");
}
#pragma mark - VoIP push methods
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
NSLog(@"voip token: %@", credentials.token);
}
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
NSDictionary *payloadDict = [payload.dictionaryPayload valueForKey:@"aps"];
NSString *message = (NSString *)[payloadDict valueForKey:@"alert"];
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertBody = [message stringByAppendingString:@" - voip"];
localNotification.applicationIconBadgeNumber = 1;
localNotification.soundName = @"notes_of_the_optimistic.caf";
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"VoIP notification" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
});
}
NSLog(@"incoming voip notfication: %@", payload.dictionaryPayload);
}
- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(NSString *)type {
NSLog(@"Voip token invalidate");
}
- 我启用了远程通知,并安装了证书和配置文件.
- 我可以使用APNS推送标准通知.
有什么可行的解决方案吗?
Any solution to get it working ?
推荐答案
证书存在问题.
重新生成并重新导入了证书,并已发布证书.
Regenerated and reimported certificates and issue fixed.
这篇关于didUpdatePushCredentials没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文