Использование схемы URL для достижения вашей цели, см. Этот код.
Введите следующий код в TodayViewController (сегодня расширение файла swift)
@IBAction func buttonTapped(_ sender: UIButton) {
let url = URL(string: "MyAppTodayExtension://")!
self.extensionContext?.open(url, completionHandler: { (success) in
if (!success) {
print("error: failed to open app from Today Extension")
}
})
}
Добавьте схему URL в ваш info.plist file
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>MyAppTodayExtension</string>
</array>
</dict>
</array>
Если вы нажмете на расширение сегодня, то получите метод вызова следующего в AppDelegate.swift файле.
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
//Write code here for navigating to a specific controller OR set root view controller
return true
}