Skip to content

Conversation

nan-li
Copy link
Contributor

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

🚧 Unit tests is WIP
🚧 Documentation is WIP
🚧 Endpoint is WIP

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.
  • Will modify the URL passed to the app, the client must handle.

New APIs:

Widget modifier
The onesignalWidgetURL something something..

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

Click tracking method
The trackClickAndReturnOriginal something something..

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

Testing

Unit testing

🚧 Unit tests is WIP

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

* Since we cache and retry this request, let's add a timestamp for the original event. This value may or may not be used by the backend, but we can see if there are indeed often delays.
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.
@nan-li nan-li force-pushed the feat/live_activities_click_events branch from c22b068 to ef32d54 Compare October 14, 2025 20:37
* Since we cache and retry this request, let's add a timestamp for the original event. This value may or may not be used by the backend, but we can see if there are indeed often delays.
@nan-li nan-li force-pushed the feat/live_activities_receive_receipts branch from 3f044ac to 2a2d695 Compare October 14, 2025 21:37
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.

1 participant