APNS & VOIP token delegate not called on iOS 13 & Xcode 11

Hi iOS devs,


I'm developing Social networking app which includes APNS for Push notification and VoIP for Voice calls. After migrated to Xcode 11.3 and in iOS 13+ devices, sometimes the device token callback not called properly.


func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// APNS Token callback
}


func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
// VOIP Token callback
}


I tried killing the app and restarting, won't help. After some different ways, i tried turning off & on network and opened my app and then above two callbacks working for me.


Also, I searched about this issue and most of developers suggesting to Restart device or turn off & on data/wifi.


I don't think this could be possible solution and it's not consistently occuring in a same device. It's occuring randomly in different iOS 13+ devices mostly on fresh installation.


Please suggest your solutions.

Thanks in Advance,

Balaji.

Hi Balaji,
I had the exact same issue as you did, it appears the system only calls pushRegistry(_:didUpdate:pushCredentials:for:) when the token is updated. See https://developer.apple.com/documentation/pushkit/pkpushregistry/1614472-pushtoken .
You can call pushToken(for:) to retrieve the token cached. It appears PKPushRegistry fetches the latest token from the system.

    func registerForVOIPNotifications()
    {
        guard voipRegistry == nil else {return}

        voipRegistry = PKPushRegistry(queue: nil)
        voipRegistry.desiredPushTypes = Set([PKPushType.voIP])
        voipRegistry.delegate = self
        useVoipToken(voipRegistry!.pushToken(for: .voIP)) // use latest token cached
    }

    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType)
    {
         useVoipToken(pushCredentials.token) // update token if needed     
    }
    
    private func useVoipToken(_ tokenData: Data?) {
        // Do whatever with the token

    }

Hope it helps.

Hugo.

I just noticed the same problem. After about 30 minutes of frantic googling (nothing relevant turning up as of Mar 26-2020), it started to work again. bhugo's solution seems to resolve it (didn't check yet...). In addition to this, so many issues for remote push notifications, especially the inconsistent accepting/rejecting criteria for the silent (bg) push notifications. I feel like quitting developing for iOS.

Hi Hugo,


Thanks for your response. I'll try this solution. 🙂

Hi Sryu,


I too faced this same after migrated to Xcode 11. It's so annoying to fix these kind of issues.

Hi Hugo,


Seems like the issue still occurs after tried your solution. The voipRegistry!.pushToken(for: .voIP) returning nil when above said issue occurs. Any other findings ?

Hi Balaji,


Same issue if for me too.


The application is not getting registered for VOIP notification suddenly. And for development (sandbox) environment it's not getting call notification too.


It's the worst issue I have faced in the iOS development ever.


Please post an update if you found anything helpful.


Thanks.

i am also facing same issue

but when i create build and export it via Adhoc enviement, push credentails are successfully save in DB, but enable to debug with dev envirement.

I see this issue Too.... Sometimes when running using XCode using Sandbox push servers I just never get thedidUpdatePushCredentials callback. It will frustrate me and then after a while it will start to work for a while..


It is very frustrating hene trying to develop code for VoIP Pushs


So far I have not seen the issue if I make an AdHoc distribution which will use the Production Push Servers. But I am worried when I deploy my solution that I will get real users seeing teh problem.


Has anybody out theree found the reason for this?

Also observed the same issue where OS stops calling back to the app to provide with push tokens. The issue happens both for APNS and PushKit tokens. Occasionally, it works for a short period and then breaks again. Have not found a treatment so far. I'm on Xcode 11.5, iOS 13.3.1

I have same problem and I have found why. Sometimes it takes more than 10 minutes to call didRegisterForRemoteNotificationsWithDeviceToken function. It has no problem before and it doesn´t take long time before. I have reported this problem. If someone have same problem, so report it!

I have same problem. However it was recovered after rebooting the phone.
Changing the network worked for me. It looks like my ISP has issues
Yes, it's same to me. Sometimes it occur like this can't receive token, must change network or turn of turn on it will be normal and sometimes receive token but when calling from other side, didReceiveIncomingPushWith not call and can't receive call, must turn off wifi turn on or restart app then can receive call.
APNS & VOIP token delegate not called on iOS 13 & Xcode 11
 
 
Q