ios – Swift: software(_: open url: choices:) not being referred to as in any respect


I am making an attempt to open a secondary view controller (not preliminary) in a single app from a special app I constructed. So I am making an attempt to deep hyperlink to a view controller that is not the preliminary one, however the perform shouldn’t be being referred to as in any respect.

I already applied openURLContexts:

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?
    
    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        print(URLContexts)
    }

Not being referred to as:

func software(_ app: UIApplication, open url: URL, choices: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

    print(url)
    let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: true)
    let host = urlComponents?.host ?? ""
    print(host)

    if host == "accessPage" {
        let storyboard = UIStoryboard(title: "Essential", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "jsonVC") as? JSONViewController
        window?.rootViewController = vc
    }
    return true
}

I added all of the information.plist stuff and made certain willFinishLaunchingWithOptions and didFinishLaunchingWithOptions each return true.

At any time when I open the second app from the primary one the first view controller is all the time the one being displayed, not the one I need which is the JSONViewController.

Here is the code from the primary app:

import UIKit

class ViewController: UIViewController {

    @IBAction func accessButtonPressed(_ sender: UIButton) {
        
        let software = UIApplication.shared
        
        let secondAppPath = "second://accessPage"
        guard let appURL = URL(string: secondAppPath) else { return }
        
        if software.canOpenURL(appURL) {
            software.open(appURL, choices: [:], completionHandler: nil)
        }
    }
}

See also  c# - iOS code signing key 'Apple Distribution: xx' not present in keychain in appcenter

Leave a Reply