I am using the twilio quickstart chat app. After binding which appears it is successful in binding to my phone with a user id because I get this message:
Request Body: {"BindingType":"apn","identity":"xxxxxxx","Address":"xxxxxxxxxxxxxxxxxxxx"}
Response Body: {"message":"Binding created!"}
Message: Binding created!
JSON: {
message = "Binding created!";
}
but
when I attempt to send a notification I keep getting a strange error.
NotifySwiftQuickstart[1304:280270] [tcp] tcp_input [C1.1:3] flags=[R] seq=17319241, ack=0, win=0 state=LAST_ACK rcv_nxt=17319241, snd_una=956992709
Not sure what that means and how to fix it so that I get the expected outcome of the notification on the phone that it's bound to.
I am running that latest Xcode version on Big Spur.
The problem was that the "Request was malformed" The push notifications were rejected by APNs.
Twilio push infrastructure does not support the notifications to not main certificate topic. So application device token and certificate subject must have the same bundle id. For instance, for VoIP notifications the certificate subject must end with ".voip" and the device token app bundle ends with ".voip".
Corrected the push notifications in the app and everything works as intended.
Related
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:
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.
I am developing a cross-platform application with xamarin forms and I'm trying to run notifications on the various devices through the notification hub.
I encounter a problem when I try to send a test notification for the iphone.
The device can register the token, received by apns, on the notification hub even if only after the '<' and '>' and spaces are deleted, otherwise, the notification hub returns the error "one or more characters in device token is not a hexadecimal digit".
However, when I try to send a first test notification, Notification Hub returns:
"The test message has been sent. Outcome: {1 success, 0 unsuccessful}"
but notification never reaches the device. All the test notifications sent subsequently result:
"The test message has been sent. Outcome: {0 success, 0 unsuccessful}"
In fact, going to see the metrics in the notification hub the next day there are some
"APNS bad Channel Error"
So what could be the problem? Did anyone have the same problem? And what does "APNS bad channel error" mean?
The APNS Bad channel error indicates the device token you are using is no longer valid. Your app on the device needs to update the token on app. You can include that as part of application restart.
Also, regarding the notication not reaching the device. Can you make sure the device is switched on and notification are turned on. You can try to set the apns-expiration header to a longer value so that apns stores the notification for redelivery for a longer time.
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW13
Thanks,
Amol
I have an iOS app that receives notification from APNS. If my user deletes the app there is no way for the backend to know the app is not installed on a certain device(device token). In this case what error code will be generated when trying to push via APNS, so that i can remove the entry from the database?
There is a Provider (Your backend server) API introduced by Apple in WWDC-2015 & enhanced in 2016 to give more valuable feedback to the server about the push notification. Here is a transcript to that WWDC session.
From the transcript: "If a device token has been removed, you will get an HTTP/2 response with status 410, or "removed."
It will have a time stamp in payload indicating when APNS last learned that the device token has been removed."
APNS Server Response Codes
200 Success
400 Bad request
403 There was an error with the certificate or with the provider
authentication token.
405 The request used a bad :method value. Only POST requests are
supported.
410 The device token is no longer active for the topic.
413 The notification payload was too large.
429 The server received too many requests for the same device token.
500 Internal server error
503 The server is shutting down and unavailable.
Now what I cannot confirm to you is that if iOS removes the device token if app is removed or if notification setting is turned off from App settings without deleting app.
"410 does mean the app was uninstalled. The token will remain active if the user disables notification alerts in the app settings. The device will still receive the notification, even if no alert is shown to the user. The server will not know if the user has turned off notification alerts. Only the app knows this."
Thanks to Marcus Adams for clartfying this doubt.
Here goes the Apple Developer Guide!!!
If required, Here is a Paid SDK that can help you with uninstallation tracking.
We are attempting to send push notifications via Azure Notification Hub and aren't able to send messages from Azure.
We've tried debugging but have been unable to figure out the error from the documentation.
How can we debug this further? We've walked through MSDN's documentation in detail but haven't been able to come up with anything
Here's our process:
We have the certificate setup in our iphone app and in Azure Notification Hub
We create our hub connection via NotificationHubClient with the debug option enabled before any Azure calls
NotificationHubClient.CreateClientFromConnectionString(NOTIFICATION_SERVICE_CONNECTION_STRING, NOTIFICATION_SERVICE_NAME, true)
We register the device upon logging into the app (and we're updating the push id if it changes)
//simplified process showing a new registration only
RegistrationDescription registration =
Hub.CreateAppleNativeRegistrationAsync(data.PushId, new List<string>() { "member:10" });
registration.RegistrationId = Hub.CreateRegistrationIdAsync().Result;
var result = Hub.CreateOrUpdateRegistrationAsync(registration).Result;
Result: We appear to get back a successful RegistrationDescription that shows our registration id, tags, device token (pushId), etag and registration id. We do show successful registration operations in the Azure Monitor.
Note: After registering the device, we don't see an increase in active devices or registrations in our Azure dashboard (0 Active Devices and 0 registrations in the dashboard)
We send a notification
// example apns: {"aps":{"alert":{"title":"TESTING","body":"Test notification"}},"MemberId":150888,"RelatedId":1,"NotificationType":2,"NotificationTypeId":2}
var notification = Hub.SendAppleNativeNotificationAsync(apns.ToJson(), "member:10").Result;
Result: We normally receive a result similar to below, however a notification is not sent
"Notification state: DetailedStateAvailable, success: 1, tracking id: xxxxxx-xxxx-xxxx-xxxx-xxxxxx, notification id: {empty} Platform: apple, Device reg id: {removed for security}, Result: The Notification was successfully sent to the Push Notification System, PnsHandle: xxx"
Other Notes: We do see several "Invalid Channel Errors", "APNS Bad Channel Error" and "APNS Expired Channel Errors" but cannot find the source. We also see several Successful Notifications logged in Azure, but never receive the notification.
The success states that you were able to request a send.
The Invalid Channel Errors and APNS Bad Channel Error indicate that you have an invalid device token. This typically happens because:
You have told NH you are using the APNS sandbox, but your app is getting tokens for APNS production.
OR
Reverse the states in #1 (NH thinks you have APNS production, your app is getting tokens for APNS sandbox)