I'm trying to show the persons name in the today view extension; but I can't seem to do this. I've watched so many YouTube video's but they never helped. So if you can, I want you to answer this.
How the app works: You type your name inside the app. And the it will show in the today view extension.
About the app: I have a text field and button. The textfield is the persons name and the button is the save the name.
I want to show the name in the today extension.
Thank you.
Add the group to the entitlements/capabilities.
Save data to NSUserDefaults with group ID and use it in your extension.
From Apple's App Extension Guide :
https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html
In the main app, save person name:
let defaults = UserDefaults(suiteName: "your group ID")
defaults!.set("person name", forKey: "key for person name")
defaults!.synchronize()
In the extension, you can use saved person name:
let defaults = UserDefaults(suiteName: "your group ID")
let savedPersonName = defaults!.string(forKey: "key for person name")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With