gpt4 book ai didi

ios - 如何在iOS中实现comet-chat时修复 "Invalid API key format"

转载 作者:行者123 更新时间:2023-11-30 11:12:21 24 4
gpt4 key购买 nike

问题是,当我要初始化 comet-chat 时,它们会生成类似 -

的错误

"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'initWithAPIKey Exception : Invalid API key format' "

我已经尝试过

第 1 步我已安装以下所有 pod

 Firebase (4.8.2)
FirebaseAnalytics (4.0.9)
FirebaseAuth (4.4.2)
FirebaseCore (4.0.14)
FirebaseDatabase (4.1.4)
FirebaseInstanceID (2.0.10)
GTMSessionFetcher (1.1.15)
GoogleToolboxForMac (2.1.4)
MessageSDKFramework (7.0.23)
cometchat-ui (7.0.23)
leveldb-library (1.20)
nanopb (0.3.8)

第 2 步。然后是我的 View Controller 的代码(我将首先初始化 comet-chat)

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var btnInitializeChat: UIButton!
@IBOutlet weak var btnLoginSuperHero1: UIButton!
@IBOutlet weak var btnLoginSuperHero2: UIButton!
@IBOutlet weak var btnLaunchChat: UIButton!
@IBOutlet weak var pbLoading: UIView!
var licenseKey : String = "XXXX-XXXX-XXXX-XXXX-XXXXX" // Replace this value with your CometChat License Key
var apiKey : String = "xxxxxxxxxxxxxxxxx" // Replace the value with your CometChat Api Key;
var UID1 : String = "xxxxxx"
var UID2 : String = "yyyyyy"
var isCometOnDemand: Bool = true; // For CometChat Cloud Users, Please set this to true

var cometChat: CometChat = CometChat();
var readyUI: readyUIFIle = readyUIFIle();


override func viewDidLoad() {
super.viewDidLoad()

}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()

}

override func viewWillAppear(_ animated: Bool) {
}

@IBAction func initializeChat() -> Void {
self.showLoading(show:true);
cometChat.initializeCometChat("http://www.gamegods.com", licenseKey:licenseKey, apikey:apiKey, isCometOnDemand:isCometOnDemand, success: {(response) in
print(" successfully initailized")
self.btnLoginSuperHero1.isEnabled = true;
self.btnLoginSuperHero2.isEnabled = true;
self.showLoading(show:false);
},failure:{(error) in
print(" Failed to initialized ")
self.showLoading(show:false);
});
}


@IBAction func loginWithSuperHero1() -> Void {
self.showLoading(show:true);
cometChat.login(withUID:UID1,success:{(response) in
print(" Successful login ")
self.btnLaunchChat.isEnabled = true;
self.showLoading(show:false);
},failure:{(error) in
print(" Failed login ")
self.showLoading(show:false);
});
}

@IBAction func loginWithSuperHero2() -> Void {
self.showLoading(show:true);
cometChat.login(withUID:UID2,success:{(response) in
print(" Successful login ")
self.btnLaunchChat.isEnabled = true;
self.showLoading(show:false);
},failure:{(error) in
print(" Failed login ")
self.showLoading(show:false);
});
}

@IBAction func launchChat() -> Void {
let isFullScreen : Bool = true;
self.showLoading(show:true);
readyUI.launchCometChat(isFullScreen, observer: self, userInfo: { (response) in
print("Launch ReadyUI Successfull ")
self.showLoading(show:false);
}, groupInfo: { (response) in

}, onMessageReceive: { (response) in

}, success: { (response) in

}, failure: { (error) in
print(" Failed ReadyUI lauch ")
self.showLoading(show:false);
}, onLogout: { (response) in
print(" Logout ")
})

}

func showLoading(show:Bool) -> Void {
if(show){
pbLoading.isHidden = false;
}else{
pbLoading.isHidden = true;
}
}

}

最佳答案

您似乎正在使用我们的Cloud SDK进行自托管安装。请注意,上面的代码仅适用于我们的 Cloud SDK,不适用于您的自托管解决方案。

如果您需要进一步帮助,您可以发送电子邮件至 https://www.cometchat.com/contact-support

(此帐户隶属于CometChat.com)

关于ios - 如何在iOS中实现comet-chat时修复 "Invalid API key format",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52053420/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com