Swift: схема URL-уведомлений на открытых не работает - PullRequest
0 голосов
/ 04 сентября 2018

Я использую ниже код:

AppDelegate:

var scheme: String!
var path: String!
var query: String!

func application(_ application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?)-> Bool {
    print("S0#: \(url.scheme)")
    print("S1#: \(url.path)")
    print("S2#: \(url.query)")

    scheme = url.scheme
    path = url.path
    query = url.query

    return true
}

ViewController:

override func viewDidLoad() {
    super.viewDidLoad()

    NotificationCenter.default.addObserver(
        self,
        selector: #selector(displayLaunchDetails(sender:)),
        name: NSNotification.Name.UIApplicationDidBecomeActive,
        object: nil)
}

@objc func displayLaunchDetails(sender: UITapGestureRecognizer) {
    var appDelegate = UIApplication.shared.delegate as! AppDelegate
    print("S: NO")
    if appDelegate.scheme != nil {
        print("S0: \(appDelegate.scheme)")
        print("S1: \(appDelegate.path)")
        print("S2: \(appDelegate.query)")
    }
}

deinit {
    NotificationCenter.default.removeObserver(
        self,
        name: NSNotification.Name.UIApplicationDidBecomeActive,
        object: nil)
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

Если я открою openUrlAfterBack:// в браузере, мое приложение откроется и только для печати S: NO

Другие данные не предоставлены и не напечатаны

В info.plist я добавил схему и идентификатор

Я узнал от: https://kitefaster.com/2016/07/13/how-to-open-ios-app-with-custom-url/

Как я могу это исправить?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...