-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Push to start live activities #1377
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brismithers
force-pushed
the
push-to-start-live-activities
branch
from
February 27, 2024 16:07
a95cdea
to
845335a
Compare
…t success/fail * Fix issue where the request could have been removed from the cache by the time the http request success/fail runs * Add ability to dismis any existing live activity with the same activityId
* Add more docs to public APIs * Handle automatic removal of stale LA requests * Refactor LA executor to be more readable
…ptions for more granular control. * Do not retry LA reqeust when retryable failure until app restarts
brismithers
force-pushed
the
push-to-start-live-activities
branch
from
March 13, 2024 16:41
f48f160
to
b4b6d62
Compare
…nalLiveActivities
… for catalyst In the example app we exclude any live activities code when building for catalyst.
Make OneSignalLiveActivitiesManagerImpl usable by objc
* Add `OneSignalLiveActivities` to the OneSignalFramework * Add `OneSignalLiveActivities` to the update_swift_package script
* Create concept of a built in "default" Live Activity widget attributes. The primary use is for cross-platform apps to more easily drive the setup and creation of a live activity. Rather than have to create their own cross-platform<->iOS bridge, they can use the OneSignal SDK to handle it. * Add tests and additional documentation, small tweaks * Create objc bindings for methods/classes to be used by wrapper SDKs * Add additional verbose logging to OneSignal.LiveActivities.setupXXX calls * Move AnyCodable and DefaultLiveActivityAttributes under Source directory
* Its dependency XCTest changed from ios to always used.
Fixes spacing, non-logic items
* The switch statements are appropriate
nan-li
force-pushed
the
push-to-start-live-activities
branch
from
May 6, 2024 23:33
6cca5d7
to
98c38d5
Compare
* So it knows of the pushToStart Apple API
nan-li
force-pushed
the
push-to-start-live-activities
branch
5 times, most recently
from
May 7, 2024 16:58
8886d1f
to
7d681fc
Compare
* Update MockOSDispatchQueue to use dispatch queue under the covers
nan-li
force-pushed
the
push-to-start-live-activities
branch
from
May 7, 2024 18:30
44c8cd3
to
005a8c1
Compare
nan-li
approved these changes
May 7, 2024
This was referenced May 10, 2024
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 wrapper SDK 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.
Preferred method to setup Live Activities with OneSignal
A new function
OneSignal.LiveActivities.setup
has been created which allows OneSignal to manage the lifecycle of a LiveActivity on behalf of the application. This includes listening for both pushToStart token updates and pushToUpdate token updates. When using this method, the application does not need to listen for pushToStart token updates, the starting of a live activity, nor update token updates. A typical usage looks like this:This method accepts any struct which adopts the
OneSignalLiveActivityAttributes
protocol. TheOneSignalLiveActivityAttributes
protocol establishes a high-levelonesignal
attribute and a high-levelonesignal
content state property which will be used internally by OneSignal. At a minimum, your attributes will have the following structure:If an application starts a live activity "in app" it no longer has to listen for token updates explicitly, starting a Live Activity "in-app" will look something like this:
Alternative (low level) method to setup Live Activities with OneSignal
If a customer app does not want to alter their
ActivityAttribute
structure, or wants more fine grained control over when OneSignal should manage a Live Activity's start/update tokens, lower-level SDK methods are provided. 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-type` each time that activity type's pushToStart token has been refreshed. 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. A typical usage looks like this:OneSignal.LiveActivities.removePushToStartToken
: To be calledper-activity-type
whenever that activity type should no longer be registered against the current subscription. A typical usage looks like this: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 theDefaultLiveActivityAttributes
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 a default Live Activity is:
Text(context.state.message)
it would be rendered asText(context.state.data["message"]?.asString() ?? "")
.Motivation
Full support of Live Activities functionality introduced in iOS 17.2
Scope
Live Activities
Testing
Unit testing
Manual testing
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is