Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can iOS Today Extension read URL Schemes from app's Info.plist

We have our app target, and in that Info.plist, we defined URL Schemes that can be used to open the app with a URL.

Now we are adding a today extension. We will want to have a table view who will open that URL from the extension. We see how that is supported in the API.

Can we get the URL scheme from the app's Info.plist, or are we basically "hard coding" the value in the extension for it to call to open?

like image 211
Jason Hocker Avatar asked Oct 20 '22 18:10

Jason Hocker


1 Answers

To get infos.plist values you can use this:

let urlTypesArray = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleURLTypes")

You can find the right key (CFBundleURLTypes) opening the info.plist as Source Code (right click)

then, find the value :

let urlSchemesValue = urlTypesArray![0]["CFBundleURLSchemes"]
print("urlSchemesValue => \(urlSchemesValue)") 
like image 182
Damien Romito Avatar answered Oct 22 '22 11:10

Damien Romito