Apple Push Notification with Sending Custom Data

Apple Push Notification with Sending Custom Data

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Apple Push Notification with Sending Custom Data

You cannot simply "click" on a standard iOS push notification to launch an arbitrary URL or deep link directly from the alert text without additional setup. The native behavior of userContent or simple custom payloads is limited; they are designed for display purposes, not immediate navigation logic. To redirect a user to a specific job detail page upon clicking the notification, you must leverage APNs (Apple Push Notification service) Custom Data combined with Universal Links.

The payload you send from your PHP job application backend must adhere to the strict JSON schema required by Apple's servers. When you construct this payload, you have two distinct parts: the headers and the content. The aps dictionary is mandatory for standard push behavior (sound, badge, alert), but the actual custom data resides outside of it in the top-level object.

Here is the structure you need to send from your server:

{
    "aps": {
        "alert": "New Job Available",
        "badge": 1,
        "sound": "default"
    },
    "jobId": "42",
    "title": "Senior PHP Engineer",
    "company": "Acme Corp"
}

In this example, jobId is the critical piece of custom data. When your iOS app receives this notification, it parses the entire JSON payload. Your app's delegate method, typically handling the didReceiveRemoteNotification: or userDidActivateFromLocalNotification lifecycle events, inspects these top-level keys.

However, knowing the jobId alone is not enough to navigate the user. You must configure your iOS application with Universal Links. This involves adding a specific scheme (e.g., acme://) to your app's entitlements and ensuring the server hosts a apple-app-site-association file that maps this scheme to your HTTPS domain (e.g., https://jobs.acmecorp.com).

When the user taps the notification, the system checks if the app is installed. If it is, the app launches and reads the custom data (jobId). Your code then constructs the deep link dynamically:

guard let jobId = userInfo["jobId"] as? String else { return }
let jobUrl = URL(string: "acme://jobs/\(jobId)")!
UIApplication.shared.open(jobUrl)

This approach ensures that even if the notification appears on a different device or is opened from a locked state, the app can interpret the custom data and route the user exactly where you intend.

Trade-offs and Pitfalls

There are specific constraints you must respect to avoid broken links or security warnings. First, Universal Links require HTTPS. You cannot host an apple-app-site-association file on HTTP; Apple's servers will reject the configuration if the domain is not secure. This is a non-negotiable requirement for your backend hosting environment.

Secondly, be mindful of data size limits. The entire APNs payload (headers + content) has a maximum size of 4KB. While adding jobId, title, and company is trivial, attempting to send large JSON blobs containing job descriptions directly in the push payload will cause the notification to fail. You must always store the full data on your server and only send identifiers or minimal summaries in the push notification.

Finally, consider the fallback behavior. If a user does not have your app installed, tapping the notification will open the URL scheme in Safari instead of launching the app. Since you are using Universal Links with HTTPS, this fallback will correctly open https://jobs.acmecorp.com/jobs/\(jobId). This provides a seamless experience for both installed and non-installed users without requiring extra logic on your PHP backend to detect the device state at push time.

If you are building a larger ecosystem where push notifications are just one component of your mobile strategy, resources like https://laravelcompany.com often provide insights into integrating these services with modern backend frameworks, though the core APNs logic remains consistent across all platforms.

Our network