0

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.

Shivam Tripathi
  • 1,405
  • 3
  • 19
  • 37
xyzcode
  • 219
  • 1
  • 7
  • 14

2 Answers2

3

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.

Patrick
  • 2,035
  • 17
  • 27
0

The method configureUserInteractions should be a custom method of your AppDelegate, so you have to implement it first, but if you just need to get a remote notification token (for Push Notifications) simply implement UIApplicationDelegate this protocol method in your AppDelegate class:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    print(deviceToken.reduce("", {$0 + String(format: "%02X", $1)})) // prints deviceToken
}
ninjaproger
  • 2,024
  • 1
  • 27
  • 26