0
votes

I have set up app group, I am able to go to application but unable to call its delegate functions or view controller delegate function which make me in trouble to navigate it to a particular page of my application.how can i solve this issue? please help me out.

 @IBAction func btnseconbutton3(_ sender: Any) {

    var responder: UIResponder? = self as UIResponder
    let selector = #selector(self.openURL(_:))
    while responder != nil {
        if responder!.responds(to: selector) && responder != self {
            responder!.perform(selector, with: URL(string: "SecurityPPSwiftFinal://")!)
            return
        }
        responder = responder?.next

    }

}

func openURL(_ url: URL) {
    return
}

//In appdelegate method

let defaults = UserDefaults(suiteName: "group.com.example.SecurityPPSwiftFinal") defaults?.synchronize()|

// In landing page i.e main view contoller will appear code

override func viewWillAppear(_ animated: Bool) { let defaults = UserDefaults(suiteName: "group.com.example.SecurityPPSwiftFinal") defaults?.synchronize() }

1
could you add more codes?Zonily Jame

1 Answers

2
votes

UIApplication object is not available in App Extensions.

For APIs not available in App Extensions, refer to: https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/ExtensionOverview.html#//apple_ref/doc/uid/TP40014214-CH2-SW2

To open the App from Today Extension use:

@IBAction func btnseconbutton3(_ sender: Any)
{
    self.extensionContext?.open(URL(string: "SecurityPPSwiftFinal://")!, completionHandler: nil)
}

To handle button tap event in AppDelegate after the app is opened, use:

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
{
    if url.scheme == "SecurityPPSwiftFinal"
    {
        //TODO: Write your code here
    }
    return true
}

For more on interaction between Today Extension and Host App, refer to: https://github.com/pgpt10/Today-Widget