Send push notifications to Mac, iOS, iPadOS, tvOS devices through your app using the Apple Push Notifications service (APNs).

Posts under APNS tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

APNS Key Vs Certificate Security
I've learned that providing an APNS “Key (Cannot expire)” instead of an APNS “Certificate (Can expire)” will provide the app "access to all topics" for all apps within the organization ‘team’ that the key is forged from. 1.) Can someone elaborate on the specifics for what that means from a security prospective? For instance, if my organization 'team' manages many applications under the same umbrella account and provides the same (or different) APNS key to each app, but one of the apps accidentally (or intentionally) wants to utilize the APNS key to affect the other apps, what are the potential consequences? And, is it possible to create a new APNS key for each app to close any security concerns for multiple apps managed under the same account, or are we stuck with every key having access to all topics?
1
1
1.1k
Jan ’24
High "Discarded - Disabled" metrics for Location Notifications
Hi everyone, I've run into an issue with push notifications in our app, specifically those related to the location push service extension. In the Push Notifications Console, there's a high number of notifications marked as “Discarded - Disabled” under Location Notifications. I'm trying to figure out what's causing this. We are seeing thousands of “Discarded - Disabled” for location but the other push types are being discarded in much smaller numbers (in the tens). Here's what I need help with: What do the different 'Discarded' categories mean in push notifications? Which are normal and which are red flags? Why are so many Location Notifications being discarded as 'Disabled'? Is this a common device setting issue? Any tips on reducing these discarded notifications, especially for location-based services? Would really appreciate your insights or any pointers towards relevant resources! Thanks! LC
0
0
267
Jan ’24
App Transfer's effect on Push Notifications
I'm in the process of preparing to receive an iOS App transferred from a 3rd party developer. It's unclear from the transfer documentation whether Push Notifications will continue to work after the transfer is complete. Could anyone provide clarity on when push notifications would begin to fail, if at all? For instance, immediately at transfer, after the first release from the new app store, or no failure until new APN tokens are created? https://developer.apple.com/help/app-store-connect/transfer-an-app/overview-of-app-transfer/
1
0
475
Jan ’24
Periodic Background Update (including force-quit)
As the title says. We have a pretty specific need for our app, and I have an idea of how to achieve it, but would like input on whether it's good practice or not. In communication apps such as Whatsapp or Discord, they need to send local notifications (and ideally update cached message data so it's fresh) anytime the user gets a new message. Conveniently for them, they control the backend, and so can just send out a silent push notification to the device(s) of user involved. In our case, we are creating a UI for someone else's backend, meaning we can't simply send a silent push on data change. What we were originally thinking was a sort of crowd-source involving a combination of silent push and background refresh, but refresh won't work if the user closes the app. I've read all the given reasons for this, and though I still disagree, there isn't anything we can do about it. So what I'm now thinking is that, at whatever interval (say 1-3hrs) some serverless function sends a silent push to every single client, which will wake them up to make a fetch and compare to the cached data and send a local notification if necessary. Downside here is it will likely incur some cost, and frankly it just feels kind of iffy as a solution, but I'm not sure what else we can do without controlling the backend API. Thoughts? Is there anything I'm missing? Any better ideas? Thanks in advance!
2
0
419
Jan ’24
NotificationService is not called
I have read through many forums but haven't found a solution for myself. When sending a notification, my NotificationService is not being called. I added it exactly as described in the official Apple tutorial and tried adding it again following other tutorials. Nothing helped. I haven't made any changes to it; it is in the same form as it is automatically created. Here it is: import UserNotifications class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent? override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { self.contentHandler = contentHandler bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) if let bestAttemptContent = bestAttemptContent { // Modify the notification content here... bestAttemptContent.title = "\(bestAttemptContent.title) [modified]" contentHandler(bestAttemptContent) } } override func serviceExtensionTimeWillExpire() { // Called just before the extension will be terminated by the system. // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { contentHandler(bestAttemptContent) } } } It does not print anything or hit any breakpoints. The notification payload looks like this: { "Simulator Target Bundle": "my.bundle", "aps": { "alert": { "title": "Its title", "body": "Very nice text" }, "sound": "default", "category": "CustomSamplePush", "mutable-content": 1 } } Things I've tried: Ensured the minimum version matches that of the application. Configured info.plist, including UNNotificationExtensionCategory. Ensured "Copy Only When Installed" is unchecked. The Content extension works. However, prints and breakpoints are also not working.
1
0
639
Jan ’24
SIP Client app - Push notification unavailable
Hello Team, We have developed an SIP Client application, where the connection is through SIP Server. We are unable to handle incoming calls when app is in the background. The local servers are blocked by firewall due to which the push notification is unavailable and is only available via VPN connection. Requesting you to please guide us on how we can receive incoming calls without push notification. We also would like to know how we can receive incoming calls when the app is completely terminated or closed from background and how to auto-start the app to receive incoming calls.
2
0
493
Jan ’24
Persistent Issue with Push Notifications on iPhone Devices
I understand that you are facing an issue with push notifications not being delivered to iPhone devices in your app since January 12, 2024, at 4:05 AM (Japan time). You've confirmed that the APNS authentication key is still valid, and the key itself is correct. Additionally, you mentioned that push notifications are working fine on the sending device. Despite resetting the authentication key, the problem persists, and you haven't received a specific error code; instead, you are getting a general error message. To troubleshoot and resolve this issue, you may want to consider the following steps: Check for Apple Server Status: Ensure that Apple's push notification servers are operational. Sometimes, server outages on Apple's end can affect push notification delivery. Review Apple Developer Console: Double-check the Apple Developer Console for any relevant messages or issues related to your app and push notifications. It might provide additional insights into the problem. Check Device Settings: Confirm that the affected iPhone devices have proper network connectivity and are not in a "Do Not Disturb" mode. Also, ensure that the app's notification settings on the user's device are configured correctly. Review Payload and Certificate: Examine the payload of your push notifications and ensure that it complies with Apple's guidelines. Additionally, verify that your app's push notification certificate is still valid. Update to the Latest SDK: Make sure that you are using the latest version of the SDK provided by Apple for handling push notifications. Contact Apple Developer Support: If the issue persists, consider reaching out to Apple Developer Support for further assistance. They may be able to provide specific insights into the problem and guide you through the resolution process. Implement Logging: Introduce logging mechanisms in your app to capture more detailed information about the push notification process. This can help you pinpoint the exact stage where the issue occurs. Network Firewall and Proxy: Check if there are any network firewalls or proxies that might be blocking the communication between your server and Apple's push notification servers. Remember to document any additional information or error messages you receive during the troubleshooting process, as these details will be helpful when seeking assistance from Apple or other developer communities. If the problem persists, seeking professional assistance or consulting with Apple's technical support may be necessary. 【Message content】 Auth error from APNS or web push Service
0
0
585
Jan ’24
Handle background notification in terminated status app
i have an issue when handling silent push in my app when the user close the app, here is my native code which works like charm when the app in the foreground, background or terminated status from a short time from closing the app, and after long time from closing it (+30min) it will not work anymore, it make me confuse why it does not work and other messaging app like viber, whatsapp and messanger you can still receive messages and calls even you swipe the app and close it !! is there any thing must i add !! override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Messaging.messaging().appDidReceiveMessage(userInfo) if Auth.auth().canHandleNotification(userInfo) { completionHandler(.noData) return } // sample notification for testing let content = UNMutableNotificationContent() content.title = "Hi there" content.body = "Just test" content.sound = UNNotificationSound.default let request = UNNotificationRequest(identifier: "helloNotification", content: content, trigger: nil) UNUserNotificationCenter.current().add(request) { (error) in if let error = error { print("Error adding notification request: \(error.localizedDescription)") } } // resent to dart side let controller: FlutterViewController = window?.rootViewController as! FlutterViewController let notificationChannel = FlutterMethodChannel(name: "notificationHandler", binaryMessenger: controller.binaryMessenger) var dataToSend: [String: Any] = [:] if let text = userInfo["text"] as? String { dataToSend["text"] = text } // Convert the dictionary to NSDictionary let nsDataToSend = NSDictionary(dictionary: dataToSend) // Pass the NSDictionary to Dart notificationChannel.invokeMethod("handleRemoteMessage", arguments: nsDataToSend) } i checked : background capabilities : remote notifs, background fetching, voip, background processing
1
0
1k
Jan ’24
Need Assistance: Unintended 'webServiceURL' Callback Triggered for All Apple Passes
I have successfully created an Apple Pass wallet with a 'webServiceURL' using PHP. The pass is added to the Apple Wallet successfully. However, when I sent a push notification to update a specific pass using its serial number, it worked as expected initially. However, in the last few days, Apple has been triggering the 'webServiceURL' callback for all passes, when we trigger a push for one pass/deviceID. I'm unsure how to prevent this callback from Apple. Please provide assistance on resolving this issue.
0
0
337
Jan ’24
[APNS][RemoteNotifications] didReceiveRemoteNotification UIBackgroundFetchResult method doesn't being called, when App is in background state, iOS swift push notification.
Hello Friends, Could you please help me, whats wrong. We have requirement that, when I receive remote notifications on device, I need to save it in to db (without tapping or opening notification banner), regardless my app is in Foreground or in Background. I receive remote notifications on device & simulator both. And UNUserNotificationCenter delegates are being called if app is in foreground, but didReceiveRemoteNotification is not calling when app is background, not killed. func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { // Save to DB completionHandler(.newData) } I am having Xcode 15.2 & I tried on iOS versions 16.x & 17.x both on Simulator and on real devices. // Added this code in App delegate UNUserNotificationCenter.current().delegate = self UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in if granted { // User granted permission DispatchQueue.main.async { UIApplication.shared.registerForRemoteNotifications() } } else { // User denied permission } }
2
0
752
Jan ’24
Push Notifications are not delivered to a good percentage of users
Hi all, In the app I developed for iOS I am using Firebase SDK (cloud messaging FCM) to provide the topic feature to deliver notification to thousands subscribed iOS users. I know FCM does not directly deliver the notifications to the final users and this is just an intermediary that formats the notification in way the APNs can understand client by client (using the APN device tokens) and this service (APNs) is in charge of delivering the notifications to the final users. The notifications are sent from a linux server through a cURL request to FCM. One example of silent notification that is like a heartbeat is below: !/bin/sh notifID=`date +"%Y%j"` value=`date -u "+%s.%N"` curl -H "Content-type: application/json" \ -H "Authorization:key=XXXXXXSECRETXXXXXX" \ -X POST -d '{ "to": "/topics/ioschannel","content_available":true,"data":{"notificationType":"silentNotification","silentNotificationId":"'$notifID'","senttime":'$value'},"priority":"high","headers":{"apns-priority":"10"},"time_to_live":60}' \ https://fcm.googleapis.com/fcm/send In the below image you can see some statistics provided by the metrics in the Apple Push Notification Console. We currently have almost 5.5k users who have mainly installed the app on their iPhones. As you can notice the APNs received a bit more than 5k notifications but what it is remarkable is the fact that only about 70% of the users receive the notification on their devices. Few notifications are on the APNs storage and delivered later on. Some devices can be offline and others are can be on power save mode but I don't understand why so many users are not receiving the notification (this particular notification is sent at 5 pm local time). Aside from the example silent notification I send other notifications to be processed in the background in the app in order to evaluate and decide to present or not a notification on the notification bar with a sound. The situation is the same, almost the same percentage don't receive the notification and almost 70% receive them on time. I have another app in Android and I don't have this problem. More than 90% of the users receive the notifications. What it is really interesting about Android is that the user can provide the permission to remove the app from the battery optimization. This is really important permission because the Android OS provides resources (network and giving priority to received push notifications) and even in power save mode the notifications are delivered. If I go straight from our linux server to APNs this situation won't change because APNs cannot deliver the notifications. Why is this happening? Is there any way to provide a permission to the app to have the highest priority? Any advice, feedback or hint will be really appreciated.
0
1
317
Jan ’24
CloudKit push notification not working on Sonoma
I have an app that uses CloudKit push notification (CKDatabaseSubscription) and it's been working all along on Ventura 13.5/Xcode 15.0. But since I upgraded my Mac to Sonoma 14.3/Xcode 15.2, my app no longer receives push notification (didReceiveRemoteNotification is not called) on the Mac. Is this a known issue of either Sonoma or Xcode 15.2? FYI, the same code works perfectly on iOS 17.2.
0
0
317
Jan ’24
Need clarity about background notifications
I want to understand if my Remote notification will be throttled based on the payload that I am sending from my backend. The confusion is due to the introduction of apns-alert-type key with possible values of alert and background. I want to understand if I set the value of apns-alert-type to alert but include the content-available key in the aps dictionary, will such notifications be throttled if sent at a more than recommended frequency of two or three per hour? I have documented by understand here in this sheet: https://docs.google.com/spreadsheets/d/13RU0tS9w4OsPpFjqPeoM0DNm045_5CF9DDdhIM9jarQ/edit?usp=sharing Also adding the same here for easy reference: Case No. apns-push-type apns-priority aps.content-available aps.alert/badge/sound My understanding Observation Notification displayed? App woken up? 1 background 5 0 absent Misconfiguration: content-available should not be 0. ❌ ❌ 2 background 5 0 present Misconfiguration: content-available should not be 0. alert/badge/sound is not alllowed. ❌ ❌ 3 background 5 1 absent Correct Configuration: This is a background notification. ❌ ✅ 4 background 5 1 present Misconfiguration: alert/sound/badge is not allowed. ❌ ✅ 5 background 10 0 absent Misconfiguration:priority 10 is not allowed. content-available should not be 0. ❌ ❌ 6 background 10 0 present Misconfiguration:priority 10 is not allowed. content-available should not be 0. alert/sound/badge is not allowed. ❌ ❌ 7 background 10 1 absent Misconfiguration: priority 10 is not allowed. ❌ ✅ 8 background 10 1 present Misconfiguration:priority 10 is not allowed. alert/sound/badge is not allowed. ❌ ✅ 9 alert 5 0 absent Misconfiguration: alert/sound/badge should not be absent. ❌ ❌ 10 alert 5 0 present Correct configuration: Alert is shown w/o waking up the app. ✅ ❌ 11 alert 5 1 absent Misconfiguration: alert/sound/badge should not be absent. ❌ ❌ 12 alert 5 1 present Correct configuration: Alert is shown with waking up the app. ✅ ✅ 13 alert 10 0 absent Misconfiguration: alert/sound/badge should not be absent. ❌ ❌ 14 alert 10 0 present Correct configuration: Alert is shown w/o waking up the app. ✅ ❌ 15 alert 10 1 absent Misconfiguration: alert/sound/badge should not be absent. ❌ ❌ 16 alert 10 1 present Correct configuration: Alert is shown with waking up the app. ✅ ✅
1
0
321
Jan ’24
push notifications on-premises
Even in the event of a disaster, push notifications are used to notify smartphone owners. However, we have received requests from customers for an app that assumes that the LTE network is disconnected due to base station inconveniences during disasters, and communication from the Apple cloud cannot be considered. In that case, you would like to send push notifications to the iOS app on-premises within the customer's server, but there is a way to do that.
2
0
343
Jan ’24
I am looking for a way to determine if this is a device polling.
When device polling occurs in the link below, is there a way to determine from the requests received on the server side whether the request was device polling? https://developer.apple.com/documentation/devicemanagement/implementing_device_management/handling_notnow_status_responses#3690890 Or can I add a specific parameter when the MDM server instructs the APNs so that the device sends the request to the MDM server with that parameter included? If this is possible, we think we can determine if the request is a polling request.
2
0
331
Jan ’24