Urgent.News

What's breaking now, across hundreds of outlets.

Tech

How to Add Images to iOS Push Notifications With a Notification Service Extension

A plain push notification is a title and a line of text. Add a photo, a product shot or a map thumbnail and people actually look at it. On iOS that's done with a Notification Service Extension (NSE): a small target that gets a chance to modify each incoming alert before it's shown. This guide walks through the whole thing, from payload to debugging, with code you can paste. 1. How it works When…

iOS push notifications can display images, enhancing user engagement. This is achieved through a Notification Service Extension (NSE), a small component that modifies incoming alerts before they're presented. Here's how it works:

1. The Notification Service Extension is triggered by APNs when it receives an alert notification with "mutable-content": 1 in its aps dictionary. iOS first notifies the NSE, which can then alter the title, body, or badge, download a file, and attach it to the notification.

2. If the NSE doesn't finish processing within 30 seconds, iOS defaults to a fallback method, showing either the modified content or the original notification.

3. The NSE only runs for alert notifications, not silent ones (content-available only). Also, "mutable-content" must be the integer 1, not the string "1" or true.

4. To set up the extension, create a Notification Service Extension target in Xcode. Ensure the bundle ID is prefixed by your app's bundle ID, and the deployment target doesn't exceed the iOS version on your test device. The extension is embedded in the app target, and no separate Push Notifications capability is required.

5. The payload sent to the server includes an image_url key outside the aps dictionary. This URL points to the image to be displayed in the notification.

6. The extension code, written in Swift, handles the received notification request. It first attempts to copy the mutable content and extract the image URL from the userInfo dictionary. If successful, it downloads the image file using URLSession. Once downloaded, the attachment is added to the content's attachments array, and the updated content is sent back to the system using contentHandler.

If time runs out before processing completes, the serviceExtensionTimeWillExpire method is called, delivering the best available content to the user.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Standardizing KMnO4 against Mohr's salt: a different n-factor, in JavaScript

KMnO4 can be standardized against two different reducing agents in Class 12 practicals: oxalic acid (a classic, needs heating) or Mohr's salt, FeSO4.(NH4)2SO4.6H2O (reacts at room temperature).

  • KMnO4 standardized using oxalic acid or Mohr's salt in Class 12 practicals
  • N-factor is 1 for Mohr's salt, 2 for oxalic acid in titration
  • Normality of KMnO4 remains consistent regardless of reducing agent used

Qdrant Tutorial: Search Your Shop by Meaning, Not Words

Quick answer Qdrant is a vector database: it stores items as lists of numbers called vectors and finds the closest matches to a query, so a search for a light summer kurta returns cotton kurtas even…

  • Qdrant is a vector database storing items as vectors
  • Enables finding closest matches to a query
  • Local database simplifies use without cloud account

Switch Java Versions per Project: update-alternatives & JAVA_HOME

The JDK 21 release page lists general availability on 19 September 2023, and JDK 25 followed on 16 September 2025; both are long-term support releases from most vendors.

  • Install Java 21 and Java 25 side by side on Ubuntu using package archive
  • Understand three Java version management levels: system default, shell override, per-build pinning
  • Diagnose version mismatches by checking system default, JAVAHOME, and build tool configurations

Node.js 20 decommissioned: fix Firebase deploy

Node.js 20 decommissioned is why your Firebase deploy now fails. Google decommissioned the Node.js 20 runtime on 30 October 2026, so functions still set to Node.js 20 can no longer be created or…

  • Node.js 20 decommissioned on October 30, 2026
  • Firebase deploys fail for projects on Node.js 20
  • Update to Node.js 22 runtime to fix deploy issues

More from Monday, 30 November 2026 →