Quickblox + Swift 3.0 iOS SDK Error: No Application Found and QBConnectionZoneTypeProduction

Quickblox + Swift 3.0 iOS SDK Error: No Application Found and QBConnectionZoneTypeProduction

我正在尝试创建一个基本的 QBRequest 并登录一个用户,或者至少返回一个用户不存在的错误。我在控制台中收到此错误。

NSErrorFailingURLKey=https://api.quickblox.com/session.json,
NSLocalizedRecoverySuggestion=
{"errors":{"base":["No application found"]}},
com.alamofire.serialization.response.error.data=<7b226572 726f7273 223a7b22 62617365 223a5b22 4e6f2061 70706c69 63617469 6f6e2066 6f756e64 225d7d7d>,
NSLocalizedDescription=Request failed: client error (422)

我已经检查了语法并完成了正确包含 SDK 的所有步骤。它继续说:"No application found"。我检查了我的凭据,并在 appDelegate 中正确输入了所有内容。

我在尝试设置端点自定义时也收到错误消息:Xcode 一直告诉我:QBConnectionZoneTypeProduction 是使用未解析的标识符..

应用委托:

     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            FIRApp.configure()

            //Quickblox config
            QBSettings.setApplicationID(myAppIdInt)
            QBSettings.setAuthKey("myAuthKeyString")
            QBSettings.setAuthSecret("myAuthSecretString")
            QBSettings.setAccountKey("myAccountKeyString")
            QBSettings.apiEndpoint("https://api....quickblox.com", chatEndpoint: "chat....quickblox.com", forServiceZone: QBConnectionZoneTypeProduction)

            // Set settings for zone
QBSettings.setApiEndpoint("https://api...quickblox.com", chatEndpoint: "chat...quickblox.com", forServiceZone: QBConnectionZoneTypeProduction)
            // Activate zone
            QBSettings.serviceZone = QBConnectionZoneTypeProduction


            // iOS 10 support
            if #available(iOS 10, *) {
                UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in }
                application.registerForRemoteNotifications()
            }
                // iOS 9 support
            else if #available(iOS 9, *) {
                UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil))
                UIApplication.shared.registerForRemoteNotifications()
            }
                // iOS 8 support
            else if #available(iOS 8, *) {
                UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil))
                UIApplication.shared.registerForRemoteNotifications()
            }
                // iOS 7 support
            else {  
                application.registerForRemoteNotifications(matching: [.badge, .sound, .alert])
            }

            return true
        }

正确的解决方案如下:

QBSettings.setApplicationID(myAppIdInt)
QBSettings.setAuthKey("myAuthKeyString")
QBSettings.setAuthSecret("myAuthSecretString")
QBSettings.setAccountKey("myAccountKeyString")

QBSettings.setApiEndpoint("https://api....quickblox.com", chatEndpoint: "chat....quickblox.com", forServiceZone: .production)

// Activate zone
QBSettings.serviceZone = .production

所以只需将 QBConnectionZoneTypeProduction 替换为 .production 这是因为 Swift3 引入了命名更改。