Member-only story
Using iOS Notifications, Cryptography and iCloud to build your own Chat App VI
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 VI, 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, and you can skip part V [the previous article] if you wish.
Ok, the plan. My problem then is that I want to ensure you don’t get unsolicited noobs from strangers, so I need to protect your token ID that we logged in the public directory.
I did try to encrypt it with your public key, but it didn’t work too well. A simpler solution would be to use a shared secret key. Here is the plan. There is a lot in here, so I’ll try and take it step by step. Let’s start with some POC code.
Firstly we need to add background modes to our app, since the initial notification is going to be a silent one. Do so opening noob project, clicking on the target and then capabilities. You want to add background Modes. Within background Modes you need to tick the box Remote Notifications.