Error 52134 Invalid APNs device token in Flutter "twilio_voice" - ios

I'm using "twilio_voice" for a flutter application for generating and receiving call from app to real number and vice versa.
When I'm trying to call to a real number from app it's working fine. But when i'm trying to receive call within the app, it's not working.
When I checked at Twilio console I found "Error 52134 Invalid APNs device token".
I have already created the VOIP certificate in Appstore console and also generated a Push Credential in Twilio console. The SID also used in the backend.
In my applog I also found "Successfully registered for VoIP push notifications." as a confirmation.
But still not working.

After your app has register for the push notification, you will need to create a binding with the Push Token to the Twilio server. For that you will need an intermediate server of your own(Can be a Node js/PHP/Python server application). First you will make a rest api request to your own server from the app. The server application will send a binding request to Twilio server. Once that is done, you will receive push notification every time there is an incoming call via didReceiveRemoteNotification() delegate in AppDelegate.
For the server application sample and Rest api sample for iOS app, follow this documentation from Twilio:
https://www.twilio.com/docs/notify/register-for-notifications-ios

Got the solution.
The issue was in the registering device. I was sending fcm token to the server for registering device. But after changing it device UUID, it worked.
Also point to be noted that, you will need a different SID from Twilio for development and Testflight. SID from Sandbox credentials won't work if you running app from TestFlight.

Related

Not Receiving Push Notifications on iOS using CapacitorJS and Ionic

Following the guide on Capacitor's site for push notifications, I am unable to receive any push notification inside my iOS device.
https://capacitorjs.com/docs/apis/push-notifications
I've triple checked that the Apple Push key and sandbox/production certificates are uploaded
I have successfully registered to the APNs and get a token value, but when I use Firebase to send a message to the token, I receive no notification.
I've also tried to send a message directly using this solution https://www.c-sharpcorner.com/UploadFile/pandeypradip/apple-push-notification-using-Asp-Net/ and I can send the message successfully, but I receive no response at all.
My app capabilities:

FCM notifications sent but never received in iOS

Update...before I ever posted
I actually discovered the solution before I posted this but thought I'd post it anyway in hopes of saving someone else's time.
As a last resort I tried deleting the APNs Authentication Key and reverting back to the certificate for the application in Firebase Cloud Messaging project settings. That fixed it. Below is the message I'd intended to post.
I'm attempting to push notifications to subscribers of a specific topic using Firebase FCM. According to the Cloud Messaging console the notifications are being sent but they're never received by a device subscribed to the topic. I'm also not receiving test messages sent via the console.
I've confirmed the following:
APNS is properly configured for my project. I was able to receive a
notification on a device using a testing site
(https://www.apnstester.com/apns/)
The topic is being subscribed to or at least subscribeToTopic doesn't
return an error.
I'm receiving a remote instance ID token.
I'm receiving an APNS device token
I've also tried:
Enabling and disabling swizzling (and yes, when it's disabled I'm
setting the APNS token)
Deleting and reloading my APNs Authentication Key
Updating the Firebase framework
Removing and re-adding the GoogleService-Info.plist
I should point out this is old app (hence the Objective-C swizzling) and notifications worked fine in the past. Any suggestions or advice?

sending gcm upstream from iOS app when app is not in foreground + gcm API for uploading APNs certificate

I have two questions about APNs push notification using gcm library.
Does gcm or fcm have a public api for uploading APNs certificates? I need to do this automatically instead of manually.
It seems that sending upstream using gcm library in an iOS app, only works when app is in foreground. Is it correct? Is there any workaround to send upstream even when app is not open or is in background? I want to send notification click event using gcm upstream to my server and it is highly preferable to do it instantly.
I am aware that I can save this click event and send it when app become active, but it is possible that user does not open the app for a long time.
1. Does gcm or fcm have a public api for uploading APNs certificates?
There is currently no public API for uploading APNs Certificates. For FCM (and any new projects), it's only done via the Firebase Console. Also, it seems that making use of the APNs Authentication Keys over certificates seem more convenient now (APNs Overview).
2. It seems that sending upstream using gcm library in an iOS app, only works when app is in foreground. Is it correct?
Yes. There has to be a connection for upstream messaging to work.
Is there any workaround to send upstream even when app is not open or is in background?
AFAIK, no. As mentioned in the FCM doc (emphasis mine):
To send messages upstream to the server, an iOS client app composes a message, connects to FCM, and calls sendMessage.
To connect, set the shouldEstablishDirectChannel flag to YES in the AppDelegate. FCM manages the connection, closing it when your app goes into the background and reopening it whenever the app is foregrounded.
...
The FCM client library caches the message on the client app and sends it when the client has an active server connection. On receiving the message, the FCM connection server sends it to the app server.
It mentions that FCM manages the connection, however AFAICT, there is this limitation for iOS devices that limits apps to maintain running services if the app is in background/closed (see this answer). And if a connection can't be established, upstream messaging won't work.
As general practice, data passed through FCM should as much as possible improve the user experience and that no app critical data is passed.
I am aware that I can save this click event and send it when app become active, but it is possible that user does not open the app for a long time.
It's possible. But it's also highly unlikely for a user to not click on a push notification immediately after it displays. In that scenario, the usual action would be for the user to immediately click on the notification while there is still an open connection.

Xamarin/Azure Notification Hubs GCM registration removed after sending

I have a Xamarin Android app setup using the GCMClient library as recommended in the Azure tutorials. When sending a notification from code or a test notification through the Azure portal (or the Azure VS plugin) the device registration is removed and the following response is received from Azure Notification Hubs:
The Push Notification System handle for the registration is no longer valid
I have commented out all code in the app that unsubscribes the registration, tried running on an emulator with the Google API's & a physical Nexus device in both debug & release mode but still the registration is removed whenever a notification is sent.
I have also configured an existing web app to use the same Azure Notification Hub; the web app uses Chrome's web push notifications with a service worker and it works perfectly, the registration is never removed from Notification Hubs and the test messages come through every time.
I have verified the usual's; Sender ID & Azure NH connection string are both correct...
A couple of things to check:
Can you check if the credentials you have set for GCM are correct.
Use this link:
https://learn.microsoft.com/en-us/azure/notification-hubs/xamarin-notification- hubs-push-notifications-android-gcm
Make sure you register with the latest device token whenever the App opens up to make sure the registrations are up to date.
I am assuming the registrations exists before you send the notification. But just to make sure, please check your registration Id using Visual studio server explorer
See link Verify Registrations

How new GCM handles APNS feedback?

I was trying out new GCM feature to send notifications to iOS devices. Everything worked very smooth except the feedback message. I assume after GCM sends message through APNS, GCM also calls feedback service of APNS to get the invalid tokens. Next time when we use the same device token to GCM, it should respond with error message. I tried several times after uninstalling the app, but never received an error message from GCM. Each time it shows success message. What went wrong here?
Note: If you are not familiar with new GCM features, please do not blindly answer to this.
I think the problem here is with the environment. I am using developer certificate to test the notification. APNS may not be giving any details for developer environment. Hope it will work in production.
Updates
Support from Google gave following details.
We did some digging, it seems that is how things are being handled by APNS:
When last sandbox app is removed from the device, device disconnects from APNS sandbox and not able to receive pushes/provide feedback anymore. Thus, APNS feedback doesn't register that the device has been uninstalled.
If you install another push-enabled sandbox app on the device, which would force device connection to APNS again. And we checked that under this circumstance, we get notified that the device has been uninstalled and return NotRegistered to our client.
APNS feedback service is not instantaneous. GCM does poll APNS feedback service but in my experience it was a bit delayed (not sure if it was APNS's delay or GCM's delay).
You should wait for some time and then try to use an old registration token and you should see a "Invalid Registration Token" error.

Categories

Resources