From the course: iOS and watchOS App Development: Notifications
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Register for notifications
From the course: iOS and watchOS App Development: Notifications
Register for notifications
- [Instructor] In order to use remote notifications you have to tell the system you want them before anything else. For this reason you'll be coding remote notifications in the app delegate. So go over to the app delegate.swift file and like any other notification you must ask permission before using them. So this is a good place for going back to the request authorization we put in much earlier and then finish launching with options. And I'm going to get rid of that for the moment so you can see everything. And so in here we've already got a print error. I'm going to add more code here. We haven't used this variable here, which is boole that says you have been granted permission. I'm going to go ahead and use that, that if we are granted permission that we're going to allow ourselves to register for remote notification. So I'm going to do if granted. I'll register for the remote. Now the remote notifications has to be done on the main thread. So we're going to have to set the correct…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.