Skip to content

Conversation

@nan-li
Copy link
Contributor

@nan-li nan-li commented Oct 13, 2025

Description

One Line Summary

Add click events for live activities, which requires considerable client integration.

Details

There are no APIs available to know of click events on a live activity or widget. The workaround implemented is to leverage deep linking and query params to know of a click and the associated live activity data.

Apple documentation:

When the widget or Live Activity receives an interaction, the system activates the containing app and passes the URL to onOpenURL(perform:), application:openURL:options:, or application:openURLs:, depending on the life cycle your app uses.

Motivation

Add analytics for Live Activities

Scope

  • No effect unless the client uses the onesignalWidgetURL modifier.
  • The SDK will modify the URL passed to the app, the client must handle.

New APIs:

Widget modifier
The onesignalWidgetURL sets the URL to open in the containing app when the user clicks the widget.

.onesignalWidgetURL(URL(string: "myapp://product/12345"), context: context)

Click tracking method
The trackClickAndReturnOriginal is used in conjunction with the onesignalWidgetURL modifier. Handle a URL opened in the app to track Live Activity clicks. Call this method from your app's URL handling code.

let originalURL = OneSignal.LiveActivities.trackClickAndReturnOriginal(url)
NSURL *originalURL = [OneSignal.LiveActivities trackClickAndReturnOriginal:url];

Testing

Unit testing

Manual testing

iPhone 13 on iOS 18.6.2

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes
  • Live Activities

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • I have reviewed this PR myself, ensuring it meets each checklist item
    • WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.

This change is Reviewable

@nan-li nan-li force-pushed the feat/live_activities_click_events branch from c22b068 to ef32d54 Compare October 14, 2025 20:37
@nan-li nan-li force-pushed the feat/live_activities_receive_receipts branch from 3f044ac to 2a2d695 Compare October 14, 2025 21:37
return false
}

// TODO: ⚠️ What is the path, method, and parameters
Copy link

@cstyles cstyles Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're reusing pushopen. See this turbine PR: https://github.com/OneSignal/turbine/pull/1628

Nope, we're going to add a new handler to live-activities-http.

Base automatically changed from feat/live_activities_receive_receipts to main October 20, 2025 20:43
@nan-li nan-li force-pushed the feat/live_activities_click_events branch from b7f9ec4 to ef32d54 Compare October 21, 2025 22:49
This is the skeleton, we still need to finalize the path and parameters
Add extension method `onesignalWidgetURL` to View and DynamicIsland that is modeled after the corresponding `widgetURL` methods in WidgetKit.
Developers call the `OneSignal.LiveActivities.trackClickAndReturnOriginal(url)` method to provide OneSignal the click tracking metadata. This method returns the intended original URL, with which they use to navigate their users.
notification ID may be nullable if the live activity is started in-app
* Use OneSignal-aware activity in the demo app
* Add onesignalWidgetURL to all OneSignal-aware activities in the demo app
@nan-li nan-li force-pushed the feat/live_activities_click_events branch from 7e26c8e to ea1ddcd Compare December 16, 2025 21:56
@nan-li nan-li requested review from a team, abdulraqeeb33 and jkasten2 December 18, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants