Я вижу устройство iOS на вкладке «Устройства» в MF, зарегистрированном в моем приложении. но отправка уведомления завершается с ошибкой ниже:
An error occurred while the notification was sent. Internal server error. No devices found.
![device list](https://i.stack.imgur.com/3KJkz.png)
При просмотре кода IOS я заметил нижеприведенную проблему при вызове MFPPush.sharedInstance.registerDevice (nil)
Cannot retrieve a valid authorization header for header. Check resource and authorization server configuration.
Я использую код из git sample . Ниже приведен фрагмент кода с ошибкой:
@IBAction func registerDevice(_ sender: AnyObject) {
print("Attempting Device registration with Mobile First")
WLAuthorizationManager.sharedInstance().obtainAccessToken(forScope: "push.mobileclient") { (token, error) -> Void in
if (error != nil) {
print("Did not recieve an access token from server: " + error.debugDescription)
} else {
WLClient.sharedInstance()?.setDeviceDisplayName("White Ipad", withCompletionHandler: { (error) in
if error == nil{
print("device display name is set")
}else{
print("error setting device name: " + error.debugDescription)
}
})
print("Recieved the following access token value: " + (token?.value ?? "no token"))
MFPPush.sharedInstance().registerDevice(nil) { (response, error) -> Void in
if error == nil {
self.enableButtons()
self.showAlert("Registered successfully with Mobile First")
print(response?.description ?? "")
} else {
self.showAlert("Registration failed with Mobile First. Error \(error?.localizedDescription)")
print(error?.localizedDescription ?? "")
}
}
}
}
}
Mobile First Config: я следовал документации и настроил проверку безопасности UserLogin из примера проекта git и удалил область действия для push.mobileclient в целях безопасности.
Читая OAuth Security в MF, я понимаю, что токен необходим для доступа к ресурсам, но я не могу понять, как подключить токен в registerDevice ().