Member-only story
Using iOS Notifications, Cryptography and iCloud to build your own Chat App VIII
I should start this article with a disclaimer, it based on iOS 13, Swift 5 and Xcode 11.x. If you reading this and those numbers look dated, be forewarned.
I should also warn you that notifications and iCloud code, involve Apple’s infrastructure which means you will need an Apple Developers account to use them.
Obviously this is part VIII, you need to go back to the beginning for it to make any sense, indeed you need to look at the notifications series before do that else your struggle. Most of the parts are just 4 minutes long including code.
What we are going to do here. Well it is time to tidy things up and indeed start to polish them up. Now thinking about it, it makes no sense that you constantly log into your device, no once you downloaded it and logged in, there is not need to do so. Lets implement that with some defaults.
It also makes sense if your logged into device A, that you don’t show yourself as a possible recipient of a message. The fix for both these reasonable easy.
@State var showUpperWheel = true...Text("noobChat").onAppear() {
cloud.getDirectory()
let name = UserDefaults.standard.string(forKey: "name")
if name != nil {
self.showUpperWheel = false
self.sender = name
messagePublisher.send(self.sender + " Logged In")
}
}