iOS Widget
Last updated
Last updated
For iOS, there are two possible Ways to bring a native Widget to iOS/iPadOS. The standard Way to add a Widget for the Homescreen is available sind iOS 14. Nevertheless, if also lower iOS Versions are supported, there is also a "Today Extension" which brings a simliar Experience to the Today Screen.
You will find the native SDK and the latest Changes here:
Unlike android, there is no need for a different SDK, the nexxPLAY SDK includes Support for both Forms of Widgets.
Since iOS 14 Apple introduced Widgets that can be added to the springboard in different sizes. They behave just as the today extensions, presenting data from their corresponding app and deeplinking into the app once the user has selected an element or the widget itself. In order to add the NexxWidget to our application, please follow these steps:
In Xcode select your project and in the targets column, add a new target via the "+" on the bottom
Select the "Widget Extension" and give it an appropriate product name
In case you are asked to activate the target, please select "Activate"
Select your new target and add the nexxPLAY framework to "Frameworks and Libraries"
Switch to "Build Phases" and add the nexxPlay.bundle to "Copy Bundle Resources"
Remove all code above the @main
in your widget code file so you only have the imports, the widget struct and its preview left.
Surround the complete code with a precompiler check for arm64 or simulators (see code example).
Configure the widget to your needs by modifying the WidgetConfiguration
and WidgetData
objects
Try and run the extension on device/simulator
In Xcode select your project and in the targets column, add a new target via the "+" on the bottom
Select the "Today Extension" and give it an appropriate product name
In case you are asked to activate the target, please select "Activate"
Select your new target and add the nexxPLAY framework to "Frameworks and Libraries"
Switch to "Build Phases" and add the nexxPlay.bundle to "Copy Bundle Resources"
In the project tree you should see a new folder with the name you gave the today extension in 2. Open the folder and open the TodayViewController
replace the code of the file with the following code:
Configure the extension to your needs by modifying the NexxPLAYWidgetConfiguration
and NexxPLAYWidgetData
objects
There should also be a "Maininterface.storyboard" that contains a UILabel by default. Please remove the label there.
There are two data objects that need to be provided for the extensions, so they can retreive and present the media data.
Attribute | Type | Value |
domain | String | the ID of the Domain (mandatory) |
launchURL | String | the deeplink that is registered to open your application with the data of the selected media (mandatory) |
feedHash | String | the Hash of the Feed, that the Widget will show |
feedSecret | String | if the target Feed is secured by a Secret, ad this Value here |
userHash | String | a valid User Reference Hash for personalized Results |
The NexxPLAYWidgetConfiguration Object is the iOS Version of the Widget Override Object. You will find all Details here:
Widget Override OptionsAdditionally the NexxPLAYWidgetConfiguration object contains overrides for the preview:
Attribute | Type | Value |
widgetPreviewImage | String | the name of an image from the apps assets that is presented in the preview |
widgetPreviewTitle | String | the preview title |
widgetPreviewInfo | String | the preview subtitle |