nexxPLAY
Search…
iOS Widget
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:
GitHub - 3qnexx/nexxPLAY-iOS
GitHub
Unlike android, there is no need for a different SDK, the nexxPLAY SDK includes Support for both Forms of Widgets.

Widget (iOS 14+)

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:
    1.
    In Xcode select your project and in the targets column, add a new target via the "+" on the bottom
    2.
    Select the "Widget Extension" and give it an appropriate product name
    3.
    In case you are asked to activate the target, please select "Activate"
    4.
    Select your new target and add the nexxPLAY framework to "Frameworks and Libraries"
    5.
    Switch to "Build Phases" and add the nexxPlay.bundle to "Copy Bundle Resources"
    6.
    Remove all code above the @main in your widget code file so you only have the imports, the widget struct and its preview left.
    7.
    Surround the complete code with a precompiler check for arm64 or simulators (see code example).
    8.
    Configure the widget to your needs by modifying the WidgetConfiguration and WidgetData objects
    9.
    Try and run the extension on device/simulator
1
#if arch(arm64) || arch(x86_64)
2
@main
3
struct MyWidget: Widget {
4
private let kind: String = "MyWidget"
5
6
var widgetData:WidgetData {
7
let config = WidgetConfiguration(app: 0, language: "de", slideUpdateInterval: nil, feedUpdateInterval: nil)
8
return WidgetData(domain: "123", deeplink: "", autoExportHash: "", autoExportSecret: "", config: config)
9
}
10
11
public var body: some WidgetConfiguration {
12
StaticConfiguration(kind: kind, provider: WidgetProvider(widgetData: widgetData)) { (entry) -> WidgetEntryView in
13
WidgetEntryView(entry: entry)
14
}
15
.configurationDisplayName("My Widget")
16
.description("my widget.")
17
.supportedFamilies([.systemSmall,.systemMedium, .systemLarge])
18
}
19
}
Copied!

Today Extension (iOS 13)

    1.
    In Xcode select your project and in the targets column, add a new target via the "+" on the bottom
    2.
    Select the "Today Extension" and give it an appropriate product name
    3.
    In case you are asked to activate the target, please select "Activate"
    4.
    Select your new target and add the nexxPLAY framework to "Frameworks and Libraries"
    5.
    Switch to "Build Phases" and add the nexxPlay.bundle to "Copy Bundle Resources"
    6.
    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
    7.
    replace the code of the file with the following code:
    8.
    Configure the extension to your needs by modifying the WidgetConfiguration and WidgetData objects
    9.
    There should also be a "Maininterface.storyboard" that contains a UILabel by default. Please remove the label there.
1
import UIKit
2
import NotificationCenter
3
import nexxPlay
4
5
class TodayViewController: UIViewController, NCWidgetProviding {
6
7
var nexxPLAYTodayView:NexxPLAYTodayView = NexxPLAYTodayView()
8
9
override func viewDidLoad() {
10
super.viewDidLoad()
11
// Do any additional setup after loading the view.
12
13
let config = WidgetConfiguration(app: nil, language: nil, slideUpdateInterval: nil, feedUpdateInterval: nil)
14
let widgetData = WidgetData(domain: "484", deeplink: "", autoExportHash: "D0T646AS2IF7S50", autoExportSecret: "", config: config)
15
16
nexxPLAYTodayView.initializeView(withData: widgetData) { media in
17
let urlString = "demoURL://..."
18
if let url = URL(string: urlString) {
19
self.extensionContext?.open(url, completionHandler: nil)
20
}
21
}
22
nexxPLAYTodayView.add(toView: self.view)
23
}
24
25
func widgetPerformUpdate(completionHandler: (@escaping (NCUpdateResult) -> Void)) {
26
nexxPLAYTodayView.widgetPerformUpdate() { (height) in
27
if let height = height {
28
self.extensionContext?.widgetLargestAvailableDisplayMode = .expanded
29
self.preferredContentSize = CGSize(width: self.view.frame.size.width, height: height)
30
completionHandler(.newData)
31
} else {
32
completionHandler(.failed)
33
}
34
}
35
}
36
37
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
38
self.preferredContentSize = nexxPLAYTodayView.widgetActiveDisplayModeDidChange(activeDisplayMode, withMaximumSize: maxSize)
39
}
40
}
Copied!

Extension data objects

There are two data objects that need to be provided for the extensions, so they can retreive and present the media data.

NexxWidgetData

Attribute
Type
Value
domain
String
the ID of the Domain (mandatory)
deeplink
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
The NexxWidgetConfiguration Object is the iOS Version of the Widget Override Object. You will find all Details here:
Last modified 1mo ago