VoIP push does not deliver on a certain iOS device - ios

We are developing a voip calling app. We are using CallKit and PushKit frameworks. A user recently reported that his iPhone is not receiving CallKit push anymore, but few days ago that was working. Please note mutable push is working on his device. We have collected device's console logs and learned that device did not receive voip push payload.
No firewalls installed and no recent change history of network settings.
Environments info:
Device Model: iPhone Xs
iOS version: 15.6.1
Network Connectivity: Wifi
This is how we registered PushKit
private func registerForVoIPPushes() {
self.voipRegistry = PKPushRegistry(queue: pushRegistryQueue)
self.voipRegistry.delegate = self
self.voipRegistry.desiredPushTypes = [.voIP]
}
We conforms the PKPushRegistryDelegate this way
extension AppDelegate: PKPushRegistryDelegate {
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
let deviceToken = pushCredentials.token.map { String(format: "%02x", $0) }.joined()
updateVoIPToken(deviceToken)
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: #escaping () -> Void) {
DDLogDebug("Incoming call voip push: \(payload.dictionaryPayload)")
handleIncomingCall(payload: payload.dictionaryPayload)
completion()
}
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
DDLogDebug("didInvalidatePushTokenFor type: \(type)")
}
}
This is how server sends voip push payload
path = '/3/device/{0}'.format({deviceToken}})
request_headers = {
'apns-expiration': '0',
'apns-priority': '10',
'apns-topic': 'com.companyname.app.voip',
'apns-push-type':'voip',
'authorization': 'bearer {auth-token}'
}
# Open a connection the APNS server
conn = HTTP20Connection('api.push.apple.com:443')
conn.request(
'POST',
path,
payload,
headers=request_headers
)
resp = conn.get_response()
print(resp.status)
print(resp.read())
The output http status code shows 200 but push actually not delivered.
Same codebase is woking fine with other devices.
I appreciate any helps and suggestions.
Thanks.

Related

IOS VoiP push doesn't work with APNS push

I have a project which use VoiP pushes for calling and APNS pushes for simple notifications. APNS push comes, but VoiP doesn't come. When server tries to send me VoiP push by my VoiP token server throws exception "Invalid Token". Please, see my solution and let me know what I do worst.
I created two certificates (APNS and VoiP)
I added certificate to identify, but I can add just APNS
Next, I generated p12 keys and send to server for using them.
In UIApplicationDelegate I retrieve APNS token and send to server
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
//next send APNS token
}
APNS token I receive successful here
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void)
VoiP push notification I register at first
func registerForPushVoipNotifications() {
let voipRegistry = PKPushRegistry(queue: DispatchQueue.main)
voipRegistry.delegate = self
voipRegistry.desiredPushTypes = [.voIP]
}
Here I receive VoiP push token
public func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, for type: PKPushType) {
let token:String? = credentials.token.map { String(format: "%02x", $0) }.joined()
//send VoiP token to server
}
By documentation sending VoiP push I must to receive here
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: #escaping () -> Void)
But when server sends VoiP push it gets error Invalid Token. What do I worst?
Firstly, you should use p8 authKey to send push notifications
Secondly, PKPushRegistry is stored in the func? This is strange. Move it to field of your class
Thirdly, try converting the token from data by the following code:
class TokenConverter {
static func token(from data: Data) -> String {
let tokenParts = data.map { data -> String in
return String(format: "%02.2hhx", data)
}
return tokenParts.joined()
}
}

VOIP Notifications through One-Signal not working

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()
}

iOS 8 - show incoming call when app is not active (without CallKit)

I received incoming call requests using PushKit/VoIP. The problem is I cannot launch the app to show incoming call screen since CallKit is not available prior to iOS 10.
I have succeeded to show notifications but how can I launch the app from background?
Here is my code:
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
if (pushCredentials.type == .voIP) {
let pkToken = (pushCredentials.token as NSData).description
SocketManager.shared.send(pkToken: pkToken)
}
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
let payloadDict = payload.dictionaryPayload["aps"] as? Dictionary<String, String>
let message = payloadDict?["alert"]
Notifications.present(id: "test", title: "test", body: message)
NSLog("incoming voip notfication 1: \(payload.dictionaryPayload)")
}

Unable to install voip app in iPhone 6

I am getting below error on running my app on iPhone 6. I am trying to implement VoIP feature.
What is the solution for this ? Any help will be appreciated. Thanks.
I am using below code for VoIP feature.
func application( _ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data ) {
let voipRegistry = PKPushRegistry(queue: DispatchQueue.main)
voipRegistry.desiredPushTypes = [PKPushType.voIP]
voipRegistry.delegate = self;
}
extension AppDelegate : PKPushRegistryDelegate {
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
NSLog("PusRegistry didUpdateCredential....")
let deviceTokenString: String = pushCredentials.token.map { String(format: "%02.2hhx", $0) }.joined()
NSLog("PushCredentials: \(deviceTokenString)" )
UIPasteboard.general.string = deviceTokenString
showLocalNotifiacation(text: "Received pushCredential")
NSLog("Token is : \(deviceTokenString)")
}
func pushRegistry(_ registry: PKPushRegistry,
didInvalidatePushTokenFor type: PKPushType) {
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
NSLog("<><><><><><><><><><><><><><><><><>><><><><><><><>><><>><><><><><")
NSLog("<><><><><><><><><><><><><><><><><>><><><><><><><>><><>><><><><><")
NSLog("<><><><><><><><><><><><><><><><><>><><><><><><><>><><>><><><><><")
NSLog("<><><><><><><><><><><><><><><><><>><><><><><><><>><><>><><><><><")
NSLog("<><><><><><><><><><><><><><><><><>><><><><><><><>><><>><><><><><")
NSLog("<><><><><><><><><><><><><><><><><>><><><><><><><>><><>><><><><><")
NSLog("<**************** Syncing data because of VOIP ***************")
sharedSilentPushSyncManager.syncDataForOperation("Syncing... for voip")
showLocalNotifiacation(text: "Received voip push")
}
}
Try this one!
1.Open your Xcode.
2.Go to your project target.
3.Click Capabilities tab in target.
4.Check with the following screenshot and enable Push Notification, Background Modes capabilities.
5.check your info.plist of your project.
6.Check your settings provided with above information and correct it.
Thank you!

Server getting error when trying to send PKPush

I am using the following code on the iOS side to get PKPush notifications working correctly. didUpdate is getting called and the server is sending a push to the correct token but the server is getting this error:
An error response packet was received from the APNS server: APNS: [1] Invalid token.
func voipRegistration() {
let voipRegistry: PKPushRegistry = PKPushRegistry(queue: DispatchQueue.main)
voipRegistry.delegate = self
voipRegistry.desiredPushTypes = [PKPushType.voIP]
}
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
//
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
//
}
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
NSLog("Device token \(deviceTokenString)")
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: #escaping () -> Void) {
//
}
I have the following background modes set:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>voip</string>
<string>fetch</string>
<string>remote-notification</string>
</array>
And I am pointing to my development certificate while the server is pointing to the sandbox. What am I doing wrong?

Resources