Learn how to implement Live Activities in OneSignal’s Wrapper SDKs like React Native, Flutter, Unity, Cordova, and more, with support for Push To Start and Default Live Activity Type.
setupDefault
methodDefaultLiveActivityAttributes
type, you can call the setupDefault
method. This method allows you to use both the Start Live Activity and Update Live Activity APIs to start/update/end the Default Live Activity.
Update your Info.plist
Info.plist
, add the key Supports Live Activities
as Boolean, and set it to YES
.Add Supports Live Activities key to Info and set its value to Boolean YES
NSSupportsLiveActivitiesFrequentUpdates
to your Info.plist as a Boolean type set to YES as directed in Apple’s Developer Docs. Users will be presented with a dialog when the Live Activity exceeds its push budget, and if they allow the Live Activity to continue, the budget will automatically be increased for a seamless user experience.Create a Widget Extension
Add a new Widget Extension target for your app in Xcode.
OneSignalWidget
) and ensure Include Live Activity is selected. Then click Finish.Widget Extension options for a Live Activity.
Widget Extension options for a Live Activity.
Add the OneSignalXCFramework to your Podfile
OneSignalWidgetExtension
.Find the name of your widget extension target
Podfile
and add the following code. Replace OneSignalWidgetExtension
with the name of your widget extension target.pod repo update && pod install
to install the OneSignalLiveActivities
pod.Allow main target membership
"event_updates"
: This is the dynamic data that can be updated after the Live Activity has been started (anything after context.state
in the code example). Since we have context.state.data we would add a data object to this field and any additional fields within like the message dictionary we have added in the code example. For usage, see example request below."event_attributes"
: This is the static data that is set in the push to start request, and remains the same value until the Live Activity is removed or overwritten."activity_id"
in the request, rather than in the code. Using different Activity ID’s will start new Live Activities. Using the same Activity ID will overwrite the widget that is currently using that ID.
DefaultActivityAttributes
type cannot be changed if you are using the default setup. Please also note, the activity type added to your path is case sensitive and should match what is defined either by you or the Default activity used in the example below.