iOS Development

ios – unable to appropriately load app for the primary time in swiftui

Spread the love


Im getting errors the primary time the swiftui utility opens.

the person first see the choice to simply accept notifications (then it goes away actually quick)
then i see the choice to permit the app to seek out and hook up with units within the community
lastly, i see the choice to simply accept notifications once more.
here’s a video of the difficulty::
https://youtu.be/d4t277ft9Os

as soon as i settle for all of the choices, i shut the app and reopen it and the whole lot works nice

That is the error that I’m seeing within the terminal ::

2024-01-12 18:14:21.503069-0500 dayt[1239:215953] Connection 1: obtained failure notification
2024-01-12 18:14:21.503131-0500 dayt[1239:215953] Connection 1: failed to attach 1:50, purpose -1
2024-01-12 18:14:21.503158-0500 dayt[1239:215953] Connection 1: encountered error(1:50)
2024-01-12 18:14:21.503892-0500 dayt[1239:215953] Process <2401ED73-1EBF-41ED-959E-2B086AB4C7B1>.<1> HTTP load failed, 0/0 bytes (error code: -1009 [1:50])
2024-01-12 18:14:21.510801-0500 dayt[1239:215955] Process <2401ED73-1EBF-41ED-959E-2B086AB4C7B1>.<1> completed with error [-1009] Error Area=NSURLErrorDomain Code=-1009 "The Web connection seems to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x2818d9230 {Error Area=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorNWPathKey=unhappy (Native community prohibited), interface: en0[802.11], ipv4, _kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <2401ED73-1EBF-41ED-959E-2B086AB4C7B1>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <2401ED73-1EBF-41ED-959E-2B086AB4C7B1>.<1>"
), NSLocalizedDescription=The Web connection seems to be offline., NSErrorFailingURLStringKey=http://192.168.0.8:3000/socket.io/?transport=polling&b64=1&EIO=4, NSErrorFailingURLKey=http://192.168.0.8:3000/socket.io/?transport=polling&b64=1&EIO=4, _kCFStreamErrorDomainKey=1}
2024-01-12 18:14:21.683981-0500 dayt[1239:215953] Connection 2: obtained failure notification
2024-01-12 18:14:21.684014-0500 dayt[1239:215953] Connection 2: failed to attach 1:50, purpose -1
2024-01-12 18:14:21.684027-0500 dayt[1239:215953] Connection 2: encountered error(1:50)
2024-01-12 18:14:21.684771-0500 dayt[1239:215954] Process <1F0C0E34-9E54-427A-A3C8-73F0572BA727>.<1> HTTP load failed, 0/0 bytes (error code: -1009 [1:50])
2024-01-12 18:14:21.685004-0500 dayt[1239:215955] Process <1F0C0E34-9E54-427A-A3C8-73F0572BA727>.<1> completed with error [-1009] Error Area=NSURLErrorDomain Code=-1009 "The Web connection seems to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x28182de60 {Error Area=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorNWPathKey=unhappy (Native community prohibited), interface: en0[802.11], ipv4, _kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <1F0C0E34-9E54-427A-A3C8-73F0572BA727>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <1F0C0E34-9E54-427A-A3C8-73F0572BA727>.<1>"
), NSLocalizedDescription=The Web connection seems to be offline., NSErrorFailingURLStringKey=http://192.168.0.8:3000/socket.io/?transport=polling&b64=1&EIO=4, NSErrorFailingURLKey=http://192.168.0.8:3000/socket.io/?transport=polling&b64=1&EIO=4, _kCFStreamErrorDomainKey=1}

that is the code that’s relevant::

// ContentView.swift
import SwiftUI

struct ContentView: View {

    @EnvironmentObject non-public var appDelegate: AppDelegate
    @EnvironmentObject var sheet_manager: SheetManager
    @ObservedObject non-public var chatViewModel = ChatViewModel()

    @AppStorage("screen_width") non-public var screen_width: String?
    @AppStorage("screen_height") non-public var screen_height: String?


    var physique: some View {
        GeometryReader { geometry in
            NavigationStack {
//                AuthView()
//                    .onAppear {
//                        screen_height = "(geometry.measurement.top)"
//                        screen_width = "(geometry.measurement.width)"
//
//                    }
            }
            .environmentObject(chatViewModel)  // Inject the ChatViewModel into the setting
        }
    }



}

code2::

// daytApp.swift
import SwiftUI


@principal
struct daytApp: App {

    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    var physique: some Scene {
        WindowGroup {
            ContentView()
                .environmentObject(appDelegate)  // Present the AppDelegate as an setting object
        }
    }
}

code3::

// AppDelegate.swift
import UIKit
import UserNotifications

class AppDelegate: NSObject, UIApplicationDelegate, ObservableObject {
    @Printed var deviceToken: String? // Observable property to replace SwiftUI view

    func utility(_ utility: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Request notification permission when the app launches
        self.requestNotificationPermission()
        return true
    }


    func requestNotificationPermission() {
        UNUserNotificationCenter.present().requestAuthorization(choices: [.alert, .sound, .badge]) { granted, error in
            if granted {
                print("Notification permission granted")
                DispatchQueue.principal.async {
                    UIApplication.shared.registerForRemoteNotifications()
                }
            } else if let error = error {
                print("Error requesting notification permission: (error.localizedDescription)")
            }
        }
    }

    func utility(_ utility: UIApplication,
                     didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Knowledge) {
        let tokenComponents = deviceToken.map { information in String(format: "%02.2hhx", information) }
        let deviceTokenString = tokenComponents.joined()

        // Replace the system token within the ObservableObject
        print("deviceTokenString: ",deviceTokenString)
        self.deviceToken = deviceTokenString
    }

}

i believe the difficulty is that the its loading to quick or one thing alongside these traces.

i discovered this stackoverflow nevertheless it dont assist::
iOS: Including SwiftUI to mission – not loading scene appropriately

Leave a Reply

Your email address will not be published. Required fields are marked *