1

I have integrated VOIP notification using OneSignal in one of my iOS app. It was working fine in earlier days of my development but suddenly it stopped working. I have checked the code and found no changes. I also created a new sample project to check for the issue but no luck. I checked the onesignal delivery dashboard which showed that the notifications are received but the (didReceiveIncomingPushWith) method is never getting called. Please help me out with the issue.

Step 1: Remote Notification Permission

if #available(iOS 10, *) {          
UNUserNotificationCenter.current().requestAuthorization(options: 
[.badge, .alert, .sound]){ granted, error in }
    } else {           
application.registerUserNotificationSettings(
UIUserNotificationSettings(types: [.badge, .sound, .alert], 
categories: nil))
}application.registerForRemoteNotifications()

Step 2: Pushkit Registration

let pushRegistry = PKPushRegistry(queue: DispatchQueue.main)
pushRegistry.desiredPushTypes = [.voIP]
pushRegistry.delegate = self

Step 3: Delegate Methods

func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
    let token = pushCredentials.token.map { String(format: "%02x", $0) }.joined()
    print("VOIP : \(token)")
}

@available(iOS, introduced: 8.0, deprecated: 11.0)
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
    //self.handlePushPayload(payload)
}

@available(iOS 11.0, *)
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
    //self.handlePushPayload(payload)
    completion()
}
Mayur Waghmare
  • 61
  • 1
  • 1
  • 4

0 Answers0