Notifications

RSS for tag

Learn about the technical aspects of notification delivery on device, including notification types, priorities, and notification center management.

Notifications Documentation

Posts under Notifications subtopic

Post

Replies

Boosts

Views

Activity

VoIP Not Working Background
Hello, I have an app which I have enabled VoIP entitlement and implemented all the CallKit and PushKit registries and delegates. I can successfully get a VoIP token. I can successfully send VoIP push notifications (and receive them via the PushKit delegate function) and then report an incoming call via CallKit, but only while my app is in the foreground. I have checked the entitlement in XCode and the Info.plist directly, and they both (as expected) show voip as a background mode. The VoIP notification is being sent via AWS SNS and everything works while the app is in the foreground. I cannot understand why the app is not waking up while in the background. This is the VoIP notification sent via SNS: aps: { alert: "Intercom call", "content-available": 1 } SNS Message Attributes: 'AWS.SNS.MOBILE.APNS.TOPIC': { DataType: 'String', StringValue: `${bundleId}` }, 'AWS.SNS.MOBILE.APNS.PUSH_TYPE': { DataType: 'String', StringValue: 'voip' }, 'AWS.SNS.MOBILE.APNS_VOIP.TTL': { DataType: 'String', StringValue: '0' }, 'AWS.SNS.MOBILE.APNS_VOIP_SANDBOX.TTL': { DataType: 'String', StringValue: '0' }, 'AWS.SNS.MOBILE.APNS.PRIORITY': { DataType: 'String', StringValue: '10' } As I say, func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) async works correctly when in the foreground. I cannot see any reason why it would not work from the background. I am also receiving normal remote notifications correctly foreground and background.
2
0
1k
Sep ’24
cPanel Version 120.0.16 Blocking Apple Push Notification (APN) service?
I am using a standard PHP script to send a push notification using a JSON web token (JWT). This works perfectly from the MacOS command line. But the same setup will not go through to the sandbox from a website on cPanel using PHP 8.3. The error is: Curl failed: Private key does not match the certificate public key There are no errors in the error logs. Any ideas?
4
0
562
Sep ’24
APNS Push sent via custom server using Certificate-based authentication not arriving
I have been trying to implement APNS Push Notifications into the iOS App I'm currently developing, and I'm having issues with notifications sent via my custom server not being delivered. I have built and ran the App on my device (iPhone running iOS 17.6.1), requested permission for notifications from UNUserNotificationCenter, and saved the device token for testing purposes. As a sanity check for the device token and the App entitlements, I used the CloudKit tool for testing Push Notifications. The notifications I send aimed at the "DEVELOPMENT" Environment work properly and arrive on the device. To configure my custom server, I created the Sandbox Apple Push Notifications certificate in my Developer portal, installed it on my Mac, exported the certificate and key together into a .p12 file, and created the PEM file using this command: openssl pkcs12 -in Certificates.p12 -out sandbox.pem -nodes -clcerts When my server attempts to send a notification, it appears to connect to the server and send the payload, but the notification never arrives on the device. I don't get any errors when my server writes the notification's binary payload to the connection. For clarity, here is the code from my server that sends the "aps" payload to APNS (written in PHP): public function sendPushNotification($deviceToken, $title, $message) { $jsonPayload = $this->composePayload($title, $message); $msg = $this->buildBinaryNotification($jsonPayload, $deviceToken); $this->connectToApns(); $result = fwrite($this->mApnsConnectionHandle, $msg, strlen($msg)); if (!$result) { $this->writeToLog("Message not delivered?!"); } else { $this->writeToLog("Message successfully delivered!"); } $this->disconnectFromApns(); } And this is the code for constructing the JSON payload, and for converting that JSON into a binary string: private function composePayload($title, $message) { // Create the payload body $body['aps'] = array( 'alert' => array( 'title'=>$title, 'body'=>$message ) ); // Encode the payload as JSON $payload = json_encode($body); return $payload; } private function buildBinaryNotification($payload, $deviceToken) { if (strlen($payload) > 0 && strlen($deviceToken) > 0) { $msg = chr(0) . pack('n', strlen($deviceToken)) . pack('H*', $deviceToken) . chr(0) . pack('n', strlen($payload)) . $payload; } return $msg; } Any suggestions or advice would be appreciated.
1
0
567
Sep ’24
Where to retrieve Live activity update token that was started with ActivityKit push notifications using push-to-start token?
I can successfully start a Live Activity using push-to-start token, but in order to update the Live Activity i need another token as stated in the docs: While the system starts the new Live Activity and wakes up your app, you receive the push token you use for updates. When the app is open, i can retrieve this update token and successfully update the Live Activity using this example code: func observeActivityPushToken() { Task { for await activityData in Activity<LiveActivityAttributes>.activityUpdates { Task { for await tokenData in activityData.pushTokenUpdates { let token = tokenData.map { String(format: "%02x", $0) }.joined() print("Push token: \(token)") } } } } } But when the app is closed, how/where do i manage to get this update token and send it to the server "when the system wakes up the app"?
2
2
731
Sep ’24
Critical Alerts and Notification Permissions
Back story: I'm developing an app that communicates with a personal medical device. We use critical alerts when we have hardware issues that could result in harm to the patient. The audio file is a 30 second file to make sure the patient is aware. If the app is open when they occur, we pop up a modal message in the app. When the user dismisses the notice, we call UNNotificationCenter::removeDeliveredNotifications(withIdentifiers:) to remove the critical alert and also to stop the audio file that is playing. This normally works fine. However we discovered that if the patient leaves critical alert enabled but disables notifications for our app, that we can still post the critical alert and it goes off. However when the user dismisses the message, the removeDeliveredNotifications call does not work. I did some debugging and if call getDeliveredNotifications with this permission combination, it return 0 (normally it would return 1). Does anyone know of another way to remove the critical alert in this situation? (or should I be submitting this as a bug?)
2
0
509
Sep ’24
APNS Connection Timed out
This error has been continuously occurring for about 9 hours. We have not replaced the certificate, modified the server code, or changed the firewall policy. Some requests succeed, but many are timing out, with several timeouts occurring every minute. We are unable to find the cause. Please help. APNS Exception io netty channel ConnecttimeException: Connection timed out
APNSOutboundHandler api.push.apple.com/17.188.169.28:443 api.push.apple.com/(other ip):443 api.push.apple.com/(other ip):443 api.push.apple.com/(other ip):443 api.push.apple.com/(other ip):443 ...
2
0
616
Sep ’24
api.sandbox.push.apple.com unavailable
Hi, since at least yesterday api.sandbox.push.apple.com is not available. It was working before, but now it seems the domain can't be resolved. I tried nslookup in the terminal. nslookup api.sandbox.push.apple.com ** server can't find api.sandbox.push.apple.com: NXDOMAIN Lookup of the production server works: nslookup api.push.apple.com Non-authoritative answer: api.push.apple.com canonical name = api-vs.push-apple.com.akadns.net. Name: api-vs.push-apple.com.akadns.net Address: 17.188.180.206 Name: api-vs.push-apple.com.akadns.net Address: 17.188.180.76 Name: api-vs.push-apple.com.akadns.net Address: 17.188.180.138 Name: api-vs.push-apple.com.akadns.net Address: 17.188.182.203 Name: api-vs.push-apple.com.akadns.net Address: 17.188.180.78 Anyone having the same problem?
1
0
581
Sep ’24
APNS Sandbox domain
A few days ago I started receiving errors from my server about it being unable to find the host api.sandbox.push.apple.com. About 10 minutes ago I tried to ping that domain and got an unknown host error. Just now I tried it again and it was able to find the host. Is there some intermittent issue with their DNS?
1
0
418
Sep ’24
Is there any way to start a live activity from a geofence trigger?
Hello, we have an app that has a case where the user can turn on a feature that starts a timer for a thing when they arrive at a specific location. Our app also has a live activity to show the timer. Naturally, we're trying to make our live activity to start counting when the geofence triggers, but we get ActivityAuthorizationError.visibility. If an activity is already running, it's possible to turn it off. So, our question is basically if there's any way to make the geofence trigger start our live activity? Thanks
3
0
748
Sep ’24
Ios18 CarPlay/BlueTooth issues
I recently updated my iOS operating system to the latest iOS18. Immediately after updating my CarPlay begin having issues. I began Troubleshooting and came up with some conclusions. If anyone can help that would be amazing. When NOT connected to carplay via cable, the Bluetooth works perfectly. When connected via cable to CarPlay the system is does not recognize Bluetooth. The phone begins to play through speakerphone, radio turns on and is playing in background. please help fix this issue. I can not have carplay not working along with Bluetooth in vehicle.
2
0
1.6k
Sep ’24
Crash register push notification swift6
Hi when setting the language to iOS 6 my app crashes on this piece of code: func registerForPushNotifications() { UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in print("Permission granted: \(granted)") guard granted else { return } self.getNotificationSettings() } } It has to do with the requestAuthorization When I restart the app it crashes immediately. This is because I had already made a choice for this. When I change the language back to swift 5 it works fine again. Removing the self.getNotifcationSettings has nothing to do with it. Also tried to add @MainActor to the function. This is the tread where it crashes on: Thread 7 Queue : com.apple.usernotifications.UNUserNotificationServiceConnection.call-out (serial) Does anybody have a idea how to fix this?
1
1
1k
Sep ’24
Only specific notification types are received from server notification.
I have set up server notification in my app. I have set up only production server URL and through that URL I can check "CONSUMPTION_REQUEST", "REFUND" notificationType. However, I want to check all notifications for in-app purchases. For example, "ONE_TIME_CHARGE" which is consumable in-app purchase type. If I want to check more notificationTypes on my server, Do I need to add another setting? Test notifications are also checked in my server. https://api.storekit.itunes.apple.com/inApps/v1/notifications/test
1
0
464
Sep ’24
AVSpeechSynthesizer don't speak on didReceive Notification Service Extension on Device(Background Mode)
My Code private let synthesizer = AVSpeechSynthesizer() override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { self.contentHandler = contentHandler bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) do { try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) let utterance = AVSpeechUtterance(string: "Hello Sim") utterance.voice = AVSpeechSynthesisVoice(language: "th_TH") utterance.rate = 1.0 utterance.pitchMultiplier = 1.0 utterance.volume = 1.0 utterance.preUtteranceDelay = 0 self.synthesizer.usesApplicationAudioSession = false self.synthesizer.speak(utterance) } catch { print(error.localizedDescription) } if let bestAttemptContent = self.bestAttemptContent { contentHandler(bestAttemptContent) } } Info.plist enable UIBackgroundModes audio fetch processing remote-notification payloadNotification { "aps":{ "alert":{ "title":"title" "subtitle":"subtitle" "body":"body" } "mutable-content":1 "content-available":1 "sound":"tester.caf" } } This code can play in simulator but can't play in real device
1
0
536
Sep ’24
When using PushKit, the Device status is offline, causing the App to be unable to receive Voip push notifications
PLATFORM AND VERSION iOS Development environment: Xcode 15.4, macOS 14.5 Run-time configuration: iOS 17.5.1  DESCRIPTION OF PROBLEM We use PushKit to push offline messages of Voip, and use Voip notifications to bind with CallKit to implement Voip call functions. During the test, we found that when the app is in the background or the screen is locked, Voip messages cannot reach the device stably. After several consecutive calls, the phone will not be able to receive new messages for a period of time. Only after the App is uninstalled and reinstalled can it continue to receive messages.  STEPS TO REPRODUCE 1: Open the app and log in successfully 2: Push the app to the background, kill it or lock the screen 3: Use another user to make a voip call to this device 4: Repeated calls
1
0
633
Sep ’24
We want to know why we don't get Voip notification
We provide users with an iOS app that sends VoIP notifications. However, we received issue from users that "VoIP notifications were not sent." So we conducted an investigation on-site and sent VoIP notifications more than 10 times to about 20 devices. We confirmed that most of the notifications arrived, but there were also times when the notifications were not sent. We would like to know if the VoIP notifications were really delivered to the devices that did not receive the notifications. If this phenomenon is a network problem, we would like to consult with the network company. We have attached the log of when we checked and the VoIP notification was not received. logs [2024-09-12 11:50:02] 'ApnsId' =&gt; '22541A6E-355E-73D6-D28F-D1F8E340E540' 'StatusCode' =&gt; 200 [2024-09-12 11:50:02] 'ApnsId' =&gt; '22541A6E-355E-73D6-D28F-D1F8E340E540' 'StatusCode' =&gt; 200 [2024-09-12 11:50:02] 'ApnsId' =&gt; '2984C9F3-CC81-9080-7B54-EF53D2E77D68' 'StatusCode' =&gt; 200 [2024-09-12 12:43:01] 'ApnsId' =&gt; 'A936595B-36F7-07C2-CFB7-3276C4BE8FC8' 'StatusCode' =&gt; 200 [2024-09-12 12:43:01] 'ApnsId' =&gt; '0C633C08-25B0-6FE2-2087-DD66C1C01532' 'StatusCode' =&gt; 200 According to these, the status code is 200. We would like to know if the VoIP notifications in the logs shown above were received by the iPhone device we tested.
5
0
432
Sep ’24
Intermittent TopicDisallowed Error with APNs
Hello, I am encountering an intermittent TopicDisallowed error while using APNs and would like to ask for your assistance. Environment: Authentication: We are using certificate-based authentication with APNs, where the PEM file is stored on the server to authenticate our requests. API: We are using the HTTP/2 API and calling the /3/device/<device_token> endpoint while passing the apns-topic in the request header. Issue: After renewing our APNs certificate, the new certificate mistakenly included an incorrect app bundle ID, resulting in a TopicDisallowed error. We then issued a new certificate with the correct bundle ID and replaced it on our server before resuming remote push requests. However, even after replacing the certificate, we are still intermittently receiving the TopicDisallowed error, while other requests successfully return a 200 OK response and deliver notifications to devices. Over time, the frequency of TopicDisallowed responses has been decreasing, leading us to speculate that APNs might be caching responses and updating this cache over time. Questions: Could you provide details on the specific conditions or causes that lead to a TopicDisallowed error? After replacing the certificate, is there a reason why we might still be intermittently receiving this error? Are there additional certificate or configuration settings we should check? What might cause some requests to succeed with a 200 OK response, while others result in a TopicDisallowed error with the same setup? Is it possible that APNs could be caching outdated information from the previous certificate, which might explain the decreasing frequency of the errors? We have reviewed our certificate and configuration after the renewal, but the issue persists. Any guidance on how to further troubleshoot or resolve this would be greatly appreciated. Thank you.
1
0
1k
Sep ’24
Sending Push Notifications to api.sandbox.push.apple.com fails
I am developing a new App that uses Push Notifications. I completed the development of the App itself and I can send Push Notifications from the CloudKit and receive it on my phone. My problem is sending the Push Notifications from our service API to Apple. If I use the production address gateway.push.apple.com, I can send messages, but they don't work for my new App because it is in development and not yet released. If I use the sandbox address api.sandbox.push.apple.com, I get the following exception: System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it. [::ffff:17.188.143.98]:2195 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Connect(EndPoint remoteEP) at System.Net.Sockets.Socket.Connect(IPAddress[] addresses, Int32 port) --- End of stack trace from previous location --- at System.Net.Sockets.Socket.Connect(IPAddress[] addresses, Int32 port) at System.Net.Sockets.Socket.Connect(String host, Int32 port) at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port) at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port) The service API for sending Push Notifications was developed in C# .NET 8.0. Constants: private readonly string _hostname = "api.sandbox.push.apple.com"; private readonly int _port = 2195; The code for sending a message. public async Task Send(string? subtitle, string? title, string message, string deviceId) { var payload = "{ \"aps\": { " + "\"alert\": { " + "\"title\": \"" + title + "\", " + "\"subtitle\": \"" + subtitle + "\", " + "\"body\": \"" + message + "\"" + "} " + "} " + "}"; try { Debug.WriteLine($"apple api request: {payload}"); using var client = new TcpClient(_hostname, _port); var sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate)); var certificatesCollection = new X509Certificate2Collection(_certificate); await sslStream.AuthenticateAsClientAsync(_hostname, certificatesCollection, SslProtocols.Tls12 | SslProtocols.Tls13, true); var array = DataToBytes(deviceId, payload); sslStream.Write(array); sslStream.Flush(); client.Close(); } catch(Exception exception) { Debug.WriteLine(exception); } } The certificate that is used in this code was read beforehand: var clientCertificate = new X509Certificate2(iOSApp.Certificate, iOSApp.CertificatePassword); We are using a p12 certificate file with a private password. Again, it works great for an App in Production but not at all for an App in Development. I made use that I use a new p12 developer certificate for the new App when I tested. I also tested with a p12 production certificate. I get the same error. Any help is appreciated.
1
0
776
Sep ’24