iosswiftdevicetoken

Swift/Obtaining a Device Token in iOS


I'm brand new to iOS development and I'm trying to figure out how to obtain a device token for iOS. I've been following the documentation as written for Swift in listing 4-1 here: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/HandlingRemoteNotifications.html

On this line: self.configureUserInteractions() (or any line referencing "self"), I'm receiving an error which says: Value of type 'AppDelegate' has no member 'configureUserInteractions'. I'm thinking maybe I'm missing an import statement in my AppDelegate.swift file, but I cant find any information on this method.


Solution

  • self.configureUserInteractions() is a method that Apple uses an example. Completely unnecessary to implement. func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) is all you need to get the device token.