I am trying to implement in-app purchases in Apple TV.
I added a "non-consumable" product and started testing in Sandbox, but it did not work properly.
While I am trying to fetch the product from the appstore, it won't give any responses like success or failure.
So that our app gets rejected in the App Store.
Please provide me the steps to implement in-app purhcase in Apple tvos using Swift.
Note: The same code is working fine in iOS.
Posts under tvOS tag
85 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I found a memory leak in tvOS 17.4, but it's not happening in tvOS 18.0
here is the code flow
1.I have controller inside which I have tableView which in turn contains a collectionview
here I have passed self to tableViewcell as delegate and then from tableview cell I have passed self again as delegate to collectionViewcell, but memory is not released, because self is retained
"I have passed self as weak every where still memory leak is happening only in tvOS 17.4 and below versions. but in 18.0 and above versions it's fine"
Description
I'm developing a tvOS application where I utilize a UISearchController embedded within a UISearchContainerViewController for search functionality. In a particular flow, a custom view controller contains a TVDigitEntryViewController as a child, with its modalPresentationStyle set to .blurOverFullScreen. The issue arises when a user initiates the PIN entry but decides to cancel and return to the search interface without entering a PIN. Upon returning, the search keyboard is no longer visible, and attempts to focus or interact with it are unsuccessful.
Steps to Reproduce
Initialize and present a UISearchContainerViewController that contains a UISearchController with a results view controller.
Within the search results, present a custom view controller containing TVDigitEntryViewController as a child, setting its modalPresentationStyle to .blurOverFullScreen.
Dismiss the custom view controller without entering a PIN (e.g., by pressing the Menu button on the remote).
Observe that upon returning to the search interface, the keyboard is missing, and focus interactions are unresponsive.
Observed Behavior
After dismissing the custom view controller with TVDigitEntryViewController, the search keyboard does not reappear, and the focus system seems to lose track of the search input field.
Expected Behavior
The search keyboard should remain visible and functional after dismissing the custom view controller, allowing users to continue their search without interruption.
Additional Context
I have reviewed the TVDigitEntryViewController documentation (developer.apple.com) and related discussions on the Apple Developer Forums but have not found a solution to this specific issue.
Questions
Has anyone encountered a similar issue or have insights into why the search keyboard becomes unresponsive after dismissing a .blurOverFullScreen modal with a child TVDigitEntryViewController?
Are there recommended practices to ensure the search keyboard remains active and focusable after such modal presentations?
Any guidance or suggestions would be greatly appreciated. Thank you!
I'm working on an Apple TVOS app and trying to upload it to the App Store. My app includes a video file that’s 8GB in size, and I’ve moved the video to On-Demand Resources to optimize its size. However, when I generate the archive, the total file size comes out to 8.4GB, which is too large for App Store submission.
Uploaded the build in the test flight but the test flight build is in progress then got the error is an invalid build.
How to upload a large build of Apple TV in the App Store using on-demand resources.
on-demand video size is 8GB
I'm working on an Apple TVOS app and trying to upload it to the App Store. My app includes a video file that’s 8GB in size, and I’ve moved the video to On-Demand Resources to optimize its size. However, when I generate the archive, the total file size comes out to 8.4GB, which is too large for App Store submission.
Uploaded the build in the test flight but the test flight build is in progress then got the error is an invalid build.
How to upload a large build of Apple TV in the App Store using on-demand resources.
on-demand video size is 8GB
I've just started working on my first SpriteKit game that will eventually run on both tvOS and iOS and am looking at how to build a "button". So far, I've got a custom node that looks like:
class MyButton: SKSpriteNode {
...
#if os(tvOS)
override var canBecomeFocused: Bool {
true
}
override func didUpdateFocus(...) {
...
}
#endif
}
The above let me nicely handle focus changes in tvOS and now I'm looking at reacting to selecting the button.
Searching around, all the articles/questions/posts are from 2015-2016 - which is a LOOOONG time ago. Most of the guidance appears to be to add a tap gesture recognizer in the owning scene and getting the scene to hand it off to the button. That seems pretty brittle and I'd much prefer if the button itself is responsible for its own tap management.
So, I guess my question is whether I should just add a gesture recognizer to my custom button class? Is this inefficient if I end up having 7-8 buttons on the screen and each one has its own gesture recognizer?
Somewhat related, all of the 10-year-old advice is that if we add recognizers to scenes, then they need to be removed from the view controller... however, in the modern day world with SwiftUI, my project doesn't even have a view controller (yet, anyway)... what gesture recognizer lifecycle management do I need in a SpriteKit scene that is presented within a SpriteKitView?
Or, is there a better way? I was kind of hoping that overriding pressesBegan() (or something similar) in my custom button might have been triggered on tvOS (like touchesBegan() lets me manage touches for the iOS variant of my app)
Any pointers or suggestions would be gladly received. Thanks.
When turning VoiceOver ON, GCController does not send button press events for "Button A" and "Button Center".
This happens when using Siri 2nd generation remote (with dedicated arrow buttons on the circle around center button) and also when using iOS remote. I didn't test it on old Siri 1st generation with touchpad without arrow buttons.
Example:
gameController.microGamepad?.allButtons.forEach { button in
button.valueChangedHandler = { [weak self] _, _, _ in
self?.buttonHandler(gameController: gameController, button: button)
}
private func buttonHandler(gameController: GCController, button: GCControllerButtonInput) {
print("BUTTON: Pressed \(button.description) isPressed=\(button.isPressed) isTouched=\(button.isTouched)")
}
#endif
VoiceOver ON (incorrect behavior):
BUTTON: Pressed Direction Pad Left (value: 0.030, pressed: 1) isPressed=true isTouched=true
BUTTON: Pressed Direction Pad Down (value: 0.079, pressed: 1) isPressed=true isTouched=true
BUTTON: Pressed Direction Pad Left (value: 0.000, pressed: 0) isPressed=false isTouched=false
BUTTON: Pressed Direction Pad Down (value: 0.000, pressed: 0) isPressed=false isTouched=false
VoiceOver OFF (correct behavior):
BUTTON: Pressed Direction Pad Left (value: 0.137, pressed: 1) isPressed=true isTouched=true
BUTTON: Pressed Direction Pad Up (value: 0.078, pressed: 1) isPressed=true isTouched=true
BUTTON: Pressed Button A (value: 1.000, pressed: 1) isPressed=true isTouched=true
BUTTON: Pressed Button Center (value: 1.000, pressed: 1) isPressed=true isTouched=true
BUTTON: Pressed Button A (value: 0.000, pressed: 0) isPressed=false isTouched=false
BUTTON: Pressed Button Center (value: 0.000, pressed: 0) isPressed=false isTouched=false
BUTTON: Pressed Direction Pad Left (value: 0.000, pressed: 0) isPressed=false isTouched=false
BUTTON: Pressed Direction Pad Up (value: 0.000, pressed: 0) isPressed=false isTouched=false
I could use for detection Direction Pad Left/Right/Up/Down and detect position between -0.7 and +0.7 and handle it as center button press, because I use that on old Siri remote where I need to distinguish center button and arrows (for switching TV channels by Up/Down and Skip forward/back by Left/Right arrows), but for new Siri remote it would be unnecessary workaround.
Does anybody know why the center/select button is not detected when VoiceOver is ON. Is there another way of detecting it using GCController?
I don't want to use SwiftUI onTapGesture for this one particular case.
Is it an unexpected bug in tvOS APIs or is there some specific reason why center button is not handled by GCController when VoiceOver is ON?
Thanks.
Hi everyone, I'm currently working on my own Apple TV app. So far, things are going pretty well, but right now, I'm stuck on the design of the categories or selection menus.
Here's a screenshot of how it looks right now:
The green color and the border are intentionally added for now so I can see what is where. My actual goal is to remove the gray bar (or is this the "main bar"?). The pink bar and its border are just design elements that can be removed if needed. I want it to look more "original," like this:
Here is the code:
let title: String
let isSelected: Bool
var body: some View {
HStack {
Text(title)
.foregroundColor(isSelected ? .black : .white)
.font(.system(size: 22, weight: .regular))
.padding(.leading, 20)
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(isSelected ? .black : .gray)
.padding(.trailing, 20)
}
.frame(height: 50) // Einheitliche Höhe für die Kategorien
.background(Color.pink) // Innerer Hintergrund auf pink gesetzt
.cornerRadius(10) // Abrundung direkt auf den Hintergrund anwenden
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.green, lineWidth: 3) // Äußerer Rahmen auf grün gesetzt
)
.padding(.horizontal, 0) // Entferne äußere Ränder
.background(Color.clear) // Entferne alle anderen Hintergründe
}
}
struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
SettingsView()
}
}
I’ve adjusted the code, but it’s still not quite right. When a category is not selected, it appears black instead of gray, like in the original design
Here is the code:
struct SettingsView: View {
@State private var selectedCategory: String?
var body: some View {
NavigationStack {
ZStack {
Color.black
.edgesIgnoringSafeArea(.all)
VStack(spacing: 0) {
// Überschrift oben in der Mitte
Text("Einstellungen")
.font(.system(size: 40, weight: .semibold))
.foregroundColor(.white)
.padding(.top, 30)
HStack {
// Linke Seite mit Logo
VStack {
Spacer()
Image(systemName: "applelogo")
.resizable()
.scaledToFit()
.frame(width: 120, height: 120)
.foregroundColor(.white)
Spacer()
}
.frame(width: UIScreen.main.bounds.width * 0.4)
// Rechte Seite mit Kategorien
VStack(spacing: 15) {
ForEach(categories, id: \.self) { category in
NavigationLink(
value: category,
label: {
SettingsCategoryView(
title: category,
isSelected: selectedCategory == category
)
}
)
.buttonStyle(PlainButtonStyle())
}
}
.frame(width: UIScreen.main.bounds.width * 0.5)
}
}
}
.navigationDestination(for: String.self) { value in
Text("\(value)-Ansicht")
.font(.title)
.foregroundColor(.white)
.navigationTitle(value)
}
}
}
private var categories: [String] {
["Allgemein", "Benutzer:innen und Accounts", "Video und Audio", "Bildschirmschoner", "AirPlay und HomeKit", "Fernbedienungen und Geräte", "Apps", "Netzwerk", "System", "Entwickler"]
}
}
struct SettingsCategoryView: View {
let title: String
let isSelected: Bool
var body: some View {
HStack {
Text(title)
.foregroundColor(.white)
.font(.system(size: 22, weight: .medium))
.padding(.leading, 20)
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(.gray)
.padding(.trailing, 20)
}
.frame(height: 50) // Einheitliche Höhe für die Kategorien
.background(isSelected ? Color.gray.opacity(0.3) : Color.clear) // Hervorhebung des ausgewählten Elements
.cornerRadius(8) // Abgerundete Ecken
.scaleEffect(isSelected ? 1.05 : 1.0) // Fokus-Animation
.animation(.easeInOut, value: isSelected)
}
}
struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
SettingsView()
}
}
Hello,
I am currently developing an application for Apple TV using TVML, and I am trying to create a user registration or login form with multiple input fields (e.g., "Username" and "Password"). However, I am facing issues with displaying multiple textField components in the formTemplate.
Here are the approaches I have tried:
Attempt 1:
<document>
<formTemplate>
<banner>
<title>Login</title>
</banner>
<banner>
<textField>UserName</textField>
</banner>
<banner>
<textField>Password</textField>
</banner>
<footer>
<button id="button1">
<text>Button 1</text>
</button>
</footer>
</formTemplate>
</document>
Attemp 2:
<document>
<formTemplate>
<banner>
<title>Login</title>
</banner>
<textField>UserName</textField>
<textField>Password</textField>
<footer>
<button id="button1">
<text>Button 1</text>
</button>
</footer>
</formTemplate>
</document>
In both cases, the layout does not render the fields as expected. Either the textField components do not display at all, or the structure seems incorrect.
Could someone please guide me on the proper way to display multiple textField components in a formTemplate? Is there a limitation or specific requirement for structuring these elements?
Thank you in advance for your assistance!
I've been trying to add a header to the tabSection of the tabview in tvos 18+ .
init(
@TabContentBuilder<SelectionValue> content: () -> Content,
@ViewBuilder header: () -> Header
) where Header : View, Footer == EmptyView
Here the ehader clearly conforms to View but i cant quite fit the label with uiimage as the icon into this. This Label when i add it to any other view, the image is in the specified 50 x 50 size but inside header it functions weirdly to be of a huge size. but also to note, if i simply hav an icon here, it is correct. So what is the problem here.. can someone help me? im supposed to add the user profile and name in the header. I dont think there's any other way
I'm running into a problem with the focus order in my UICollectionView in my tvOS app. The layout of my app is outlined in the following diagram
On the uppermost layer I have a UITableView, each cell containing a single UICollectionView that can contain a variable number of UICollectionViewCells.
When the user swipes down, I want the left-most item in the next row down to be selected, as follows:
I've been able to get this to work for the majority of cases. The exception is when the previously focused item extends to the length of the screen - in this case the next focused item isn't the leftmost item, but rather the center item, as follows.
Using focus guides won't really fit the use case here since collection views are dynamically generated.
I've found that there is a function in UICollectionViewDelegate, indexPathForPreferredFocusedView that should help here but it only seems to be called intermittedly, even though I have set remembersLastFocusedIndexPath on the collectionview to true. I can force it to be called by calling setNeedsFocusUpdate() but I can't figure out a good place to call it - shouldUpdateFocus is too early and didUpdateFocus is too late.
Is there some way to constrain the focus area of a view to a certain subset of it's frame - for example, the left-most quarter of its width?
Or does anyone know of some other solution to this problem?
I'm developing a grid of focusable elements in SwiftUI with different sizes for tvOS (similar to a tv channel grid).
Because the Focus Engine calculates the next view to focus based on the center of the currently focused view, sometimes it changes focus to an unexpected view. Here's an example:
Actual:
Expected:
Is it possible to customize the anchor point from which the focus engine traces a ray to the next view? I would prefer the leading edge in my case.
I'm trying to make the side bar menu on my tvOS app have the same behavior of Apple's tvOS App. I would like to have the side menu collapsed at the cold start of the app. I'm trying to achieve this by using the defaultFocus view modifier, which should make the button inside the TabView focused at the start of the app. But no matter what I do, the side bar always steels the focus from the inside button.
struct ContentView: View {
enum Tabs {
case viewA
case viewB
}
enum ScreenElements {
case button
case tab
}
@FocusState private var focusedElement: ScreenElements?
@State private var selectedTab: Tabs? = nil
var body: some View {
Group {
TabView(selection: $selectedTab) {
Tab("View A", image: "square", value: .viewA) {
Button("View A Button", action: {})
.frame(maxWidth: .infinity, alignment: .center)
.focused($focusedElement, equals: .button)
}
}
.tabViewStyle(.sidebarAdaptable)
.focused($focusedElement, equals: .tab)
}
.defaultFocus($focusedElement, .button, priority: .userInitiated)
}
}
Is there a way to start the side bar menu collapsed at the start up of the app?
A new app I have submitted to Apple App Review for iOS/tvOS/macOS has been rejected for tvOS because it is apparently crashing on launch. The same build has been approved by App Review for iOS and macOS.
So far, App Review have not provided me with a crash report, and despite a lot of trying, I cannot get the crash to occur either on a real device or on any version of the Apple TV in the simulator.
Apart from constantly asking App Review for the crash report, I don't know how to resolve this, and that means I either have to give up on tvOS for this app, delay the launch, or perhaps start another submission and get lucky with a different reviewer that doesn't experience the crash (but then what if lots of users do?).
I've tried running a release build on my devices and the simulator; but I'm not sure how I'm supposed to debug this without a crash to work with. The TestFlight build for the same upload that is crashing for App Review works just fine.
Any suggestions would be welcome.
After many former OS and Xcode updates, my Game Controller Swift code generates a "DIS-CONNECTED" MESSAGE.
Mac Sequoia 15.2
Xcode 16.2
Tried to update PlayStation controller firmware on my Mac.
Still no luck with Xcode and its use of a game controller with tvOS.
I recently tried Apple TV after using android tv for a long time.
The main missing item is having a browser. I could not find one.
i tried building Firefox for TVOS, it failed with WebKit not available.
Is there a way to build WebKit and package it along with a browser package while building it?
I'm developing a tutorial style tvOS app with multiple videos. The examples I've seen so far deal with only one video.
Defining the player and source(url) before body view
let avPlayer = AVPlayer(url: URL(string: "https://domain.com/.../.../video.mp4")!))
and then in the body view the video is displayed
VideoPlayer(player: avPlayer)
This allows options such as stop/start etc.
When I try something similar with a video title passed into this view I can't define the player with this title variable.
var vTitle: String
var avPlayer = AVPlayer(url: URL(string: "https://domain.com/.../.../" + vTitle + ".mp4"")!))
var body: some View {
I het an error that vTitle can't be used in the url above the body view.
Any thoughts or suggestions? Thanks
I have a TVML style app on the app store that no longer seems to work. I'm working on converting it to SwiftUI after seeing the WWDC video "Migrate your TVML app to SwiftUI".
I've got most of the code working up until I'm trying to display video from a remote source (my website). It looks like the network connection is blocked, maybe.
On a macOS app I see a App Sandbox capabilities that include Network access. I don't see that option for the tvOS app. Am I missing something or is it not needed, and I should look elsewhere?
Thanks, David
Hi, so a little context, by environment variables I mean like $HOME in linux. I know that there are some standard and some app specific environment variables in the above mentioned platforms.
Is is possible for the user to set environment variables? If so, what are the ways in which users can set environment variables in the platforms mentioned across the system or for the app as they would in macOS/linux/windows?
And is it possible for developers of the app do the same? If so how?
What I have found so far is that it cannot be done by users, and there is one place in xcode where I, as a developer can set environment variables for my app from the scheme. This isn't available when I ship just the installation binary to the end user, but rather is available only when the app is run using xcode. I just need validation that what I understand is correct and that there aren't other ways to do this by the user/developer without jailbreaking.
I've seen the Multiview feature on tvOS that displays a small grid icon when available. However, I only see this functionality in VisionOS using the AVMultiviewManager. Does a different name refer to this feature on tvOS?
Relevant Links:
https://www.reddit.com/r/appletv/comments/12opy5f/handson_with_the_new_multiview_split_screen/
https://www.pocket-lint.com/how-to-use-multiview-apple-tv/#:~:text=You'll%20see%20a%20grid,running%20at%20the%20same%20time.