I want to implement VoIP notifications in my iOS application, But the didUpdatePushCredentials method never got called, I can\'t get the device token.
Use below code and Make sure about following things.
**`**// Register for VoIP notifications**`**
- (void) voipRegistration {
dispatch_queue_t mainQueue = dispatch_get_main_queue();
// Create a push registry object
_voipRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue];
// Set the registry's delegate to self
[_voipRegistry setDelegate:(id _Nullable)self];
// Set the push type to VoIP
_voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
}
Call Below method in didFinishLaunchingWithOptions
Other deleget method as follow
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials: (PKPushCredentials *)credentials forType:(NSString *)type {
// Register VoIP push token (a property of PKPushCredentials) with server
if([credentials.token length] == 0) {
NSLog(@"voip token NULL");
return;
}
NSLog(@"%@",credentials.token);
}
//Make sure about this in project capabilities
1)Background mode is ON
2)VOIP
3)Background Fetch
4)remotenotification
5) Dont forgot to import delegate
inside the Background MODE