Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Update SDK to support Live Activities PushToStart and add a concept of a "Default" Live Activity to facilitate easier adoption.
Details
Push to Start Live Activities
Starting with iOS 17.2, Live Activities can now be started via push notification (Apple's documentation). This change enhances the OneSignal SDK to provide application's access to the full suite of Live Activity functionality.
Default Live Activity
The concept of a "Default" Live Activity has been established in the SDK, which eliminates the need for a customer app to define and manage their own
ActivityAttributes
. This is most beneficial for wrapper-SDKs, as they will no longer need to create their own cross-platform <-> native iOS bridge to establish this management. The following new external interfaces are provided for customer app's to use:DefaultLiveActivityAttributes
struct which conforms toOneSignalLiveActivityAttributes
(i.e. a OneSignal awareActivityAttributes
). A customer app can create a widget withActivityConfiguration(for: DefaultLiveActivityAttributes.self)
to use this provided model. TheDefaultLiveActivityAttributes
establishes a dynamic dictionary of attributes, able to consume any customer-provided structure of data.OneSignal.LiveActivities.SetupDefault()
which tells the OneSignal SDK to manage the LiveActivity lifecycle for the nativeDefaultLiveActivityAttributes
type. When calling this method, a customer can use both 'push-to-start' and push-to-update notifications to start/update/end their Default Live Activity.OneSignal.LiveActivities.StartDefault(activityId, activityAttributes, initialContentState)
which allows a customer app to start a live activity based on theDefaultLiveActivityAttributes
type "in app".The downside to using the default Live Activity is:
Text(context.state.message)
it would be rendered asText(context.state.data["message"]?.asString() ?? "")
.Alternative (low level) method to setup Live Activities with OneSignal
If a customer app does not want to use the default live activity they can still create their own native
ActivityAttribute
structure and manage the live activity lifecycle themselves. These methods require the application to listen for pushToStart token updates, the starting of live activities, and update token updates. This encompasses existingfunctions
OneSignal.LiveActivities.Enter
andOneSignal.LiveActivities.Exit
which are documented here. Additional new methods to cover registering/unregistering pushToStart tokens have been created:OneSignal.LiveActivities.SetPushToStartToken
: To be called 'per-activity-typeeach time that activity type's pushToStart token has been refreshed. An "activity type" is the name of the
ActivityAttribute` structure. The new pushToStart tokens are sync'd to the OneSignal backend and registered against the current subscription, where it can be the target of a started live activity.OneSignal.LiveActivities.RemovePushToStartToken
: To be calledper-activity-type
whenever that activity type should no longer be registered against the current subscription.Motivation
Full support of Live Activities functionality introduced in iOS 17.2
Scope
Live Activities
Testing
Manual testing
Enter
,Exit
,SetPushToStartToken
, andRemovePushToStartToken
. Note that the lower level methods send the dummy tokens provided as input to the app, the example app does not show how to create a unity<->ios native bridge to manage live activities.IPostprocessBuildWithReport
was established for the app to inject the widget extension into the xcode build as part of the unity build process.Affected code checklist
Checklist
Overview
Testing
Final pass
This change is