无法将IOS设备注册到Mobile First 8

时间:2018-11-11 14:14:17

标签: ibm-mobilefirst ibm-mobilefirst-windows

我可以在MF的“设备”选项卡下看到注册到我的应用程序的iOS设备。但推送通知失败并显示以下错误:

An error occurred while the notification was sent. Internal server error. No devices found.

device list

在审查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:我已按照文档进行操作,并从示例git项目配置了UserLogin安全性检查,并删除了安全性下push.mobileclient的范围。

通过阅读MF中的OAuth安全性,我了解到令牌是访问资源所必需的,但是我无法弄清楚如何将令牌附加到registerDevice()中。

1 个答案:

答案 0 :(得分:0)

似乎您没有在MobileFirst Server中正确配置推送通知。

  • 确保已在应用程序的“安全性”选项卡中添加了push.mobileclient范围。如果您不使用任何安全检查,则可以添加以下范围。 enter image description here

  • 检查您的应用程序是否配置了有效的通过推送功能启用的iOS供应配置文件

  • 确保已在MFP操作控制台中特定应用程序的“推送”选项卡中上载了有效的沙箱/生产证书。 更多详细信息:here

  • 确保在项目设置中启用了应用程序的“推送功能”,并检查您使用MFPPush.sharedInstance().sendDeviceToken(deviceToken)文件didRegisterForRemoteNotificationsWithDeviceToken方法中的AppDelegate API向MF Server发送设备令牌< / p>

  • --