Silent pushes not delivered to the app on iOS 11
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Silent push notifications are a powerful tool that allows apps to perform background actions without alerting the user directly. They are typically used for background content updates, refreshing app data quietly, or collecting usage analytics. However, with iOS 11, many developers encountered issues with silent pushes not being delivered to their apps, or not behaving as expected, which impacted user experience and app performance.
Understanding Silent Push Notifications
A silent push notification is sent to the user’s device without causing any visible alert or sound. Its primary goal is to wake up the app in the background to perform a task, such as downloading content. This functionality is essential for maintaining a seamless user experience, especially for apps that rely on fresh content.
Key Characteristics:
- No Alert or Sound: Users are not notified; the notification is handled silently.
- Background Execution: Invokes app background refresh without bringing the app to the foreground.
- Efficiency: Minimizes the power and data usage as compared to regular push notifications.
Issues with iOS 11
With the release of iOS 11, developers noticed that silent push notifications were not reliably reaching their apps. The reasons can be traced back to several changes Apple made regarding how background tasks and notifications are handled. Here’s a deeper look into the contributing factors:
Changes in Background Execution
iOS 11 introduced stricter controls on background execution to enhance battery life and overall system performance. These changes had direct implications on the delivery of silent push notifications:
- Background App Refresh: Previously, apps could maintain persistent background activities, but under iOS 11, these abilities were restricted. If an app is terminated, it might not receive silent pushes as expected.
- App States: Silent pushes only work efficiently if the app is in a suspended state but not if it has been manually terminated by the user.
Network Availability and Conditions
Another crucial factor affecting silent push delivery is network availability and conditions:
- Transient Connections: If the device is in a low connectivity area or switched to flight mode, silent pushes may fail to be delivered.
- Data Saver Modes: With data-saving features turned on, background processes, including silent push delivery, might be limited.
Server Configurations and Payload Size
There are also server-side and configuration aspects to be cognizant of:
- Payload Size: The payload for a silent push should not exceed 4 KB. Larger payloads might be rejected by the APNs (Apple Push Notification service).
- Content-Available Flag: The payload must include
"content-available": 1to signal the operating system to initiate a background download operation.
Mitigating Delivery Issues
To improve the reliability of silent push notifications on iOS 11, developers can adopt several strategies:
Optimize App Configuration
- Enable Background Modes: Ensure that background app refresh is enabled under capabilities in Xcode, and the necessary permissions are granted by the user.
- Use Remote Notification Key: In the
Info.plist, add theUIBackgroundModeskey withremote-notificationto specify your app can receive silent push notifications.
Server-Side Adjustments
- Send Test Pushes: Regularly test the delivery of silent pushes across different network conditions and app states.
- Optimize Payload Content: Keep payload size minimal, strictly adhering to Apple’s 4 KB limit.
Alternate Solutions
- Local Notifications: For some use-cases, consider using local notifications to keep the app’s content fresh while providing users more control.
Conclusion
The challenges associated with silent pushes not being delivered on iOS 11 can be frustrating, but they underscore the importance of adapting to platform updates and optimizing application performance within new constraints. By understanding the intricacies of iOS 11's background execution policies and adjusting both client-side and server-side mechanisms, developers can ensure a more reliable experience for users.
Summary Table
| Key Aspect | Details & Recommendations |
| Background Execution | Enable necessary background modes; Ensure app is not manually terminated. |
| Network Conditions | Ensure stable network connections; Test in varied scenarios. |
| Payload Constraints | Keep within 4 KB; Include content-available |
| flag. | |
| User Permissions | Inform users to enable background app refresh for seamless updates. |
| Alternate Mechanism | Use local notifications for critical updates if silent pushes are unreliable. |
| Regular Testing | Validate delivery paths across varied states and conditions. |
Developers should consistently monitor Apple's updates on push notification services and background execution policies to be proactive in optimizing their applications.
Related reading
- Simple and clean way to convert JSON string to Object in Swift
- Simple and clean way to convert JSON string to Object in Swift
- Simple Android grid example using RecyclerView with GridLayoutManager like the old GridView
- Simple Android RecyclerView example
- Silverlight HttpWebRequest.Create hangs inside async block
- Similar code in Tasks returning different status codes
- Simplest way to throw an error/exception with a custom message in Swift?
- Simplest way to throw an error/exception with a custom message in Swift?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.