Error with tutorial Push Notifications

Hi in the Push Notifications Tutorial: Getting Started I am getting the error “Cannot find ‘self’ in scope” under
func registerForPushNotifications()

https://www.raywenderlich.com/11395893-push-notifications-tutorial-getting-started

Any ideas how to clear error?
Thank you

@sa44 Thanks very much for your question!

Is it possible for you to paste the full function to show what it is you are referring to?

Sure

func registerForPushNotifications() {
UNUserNotificationCenter.current()
.requestAuthorization(
options: [.alert, .sound, .badge]) { [weak self] granted, _ in
print(“Permission granted: (granted)”)
guard granted else { return }
self?.getNotificationSettings()

  }

}

So sorry. It was my fault. I put the function outside of the AppDelegate class. opps!. Thanks for your time

This topic was automatically closed after 166 days. New replies are no longer allowed.