Open main App via TodayExtension iOS Swift
Problem:
I had developed an app with today extension.How do navigate to my main app when the user clicks any data in my extension?
Solution:
In Today extension if you click the logo default it will navigate to the app.You can use the below coding in your extension
In extension write the below code:
let url = URL(string:"Widget://data you want to send to main app")
self.extensionContext?.open(url!, completionHandler: { (success) in
if (!success) {
print("error: failed to open app from Today Extension")}
})
In your main app handle the data from the url and process it.
In Main app write the below code:
func application(_ application: UIApplication, handleOpen url: URL) -> Bool
{
if url.scheme == "Widget" {
if let value = url.host
{
"process the value here"
}
}
return true
}
I had developed an app with today extension.How do navigate to my main app when the user clicks any data in my extension?
Solution:
In Today extension if you click the logo default it will navigate to the app.You can use the below coding in your extension
In extension write the below code:
let url = URL(string:"Widget://data you want to send to main app")
self.extensionContext?.open(url!, completionHandler: { (success) in
if (!success) {
print("error: failed to open app from Today Extension")}
})
In your main app handle the data from the url and process it.
In Main app write the below code:
func application(_ application: UIApplication, handleOpen url: URL) -> Bool
{
if url.scheme == "Widget" {
if let value = url.host
{
"process the value here"
}
}
return true
}
Comments
Post a Comment