我使用自定义自动识别令牌启动FirechatUI,但是未捕获错误:FirechatUI:缺少必需参数el
乔:81对象
我怀疑这是因为authData的uid字段为空(auth:" {" uid":" joe"}" .. 。" uid":null)
chatRef.onAuth(function(authData) {
if (authData) {
console.log(authData);
var chat = new FirechatUI(chatRef, document.getElementById('firechat-wrapper'));
chat.setUser(authData.uid,authData[authData.provider].displayName);
}
}
});
我在GoLang中创建auth令牌,如下所示
func genChatToken(username string) (string, error) {
token := jwt.New(jwt.SigningMethodHS256)
token.Claims["v"] = 0
token.Claims["iat"] = time.Now().Unix()
json, err := json.Marshal(map[string]string{
"uid": username,
})
if err != nil {
return "", err
}
token.Claims["d"] = string(json)
return token.SignedString([]byte("..."))
}
并自动验证为
chatRef.authWithCustomToken({{ .params.token }}, function(error, authData) {
if (error) {
console.log(error);
}
});
下面的Stacktrace
firechat.min.js:2 Uncaught Error: FirechatUI: Missing required argument `el`
firechat.min.js:2 t
joe:82 (anonymous function)firebase-debug.js:5400
fb.core.util.EventEmitter.onfirebase-debug.js:11989
Firebase.onAuthjoe:79 (anonymous function)
答案 0 :(得分:0)
' el'参数是指FirechatUI将聊天窗口注入的div。如果你的消息包装'当您实例化FirechatUI时,div不存在,那么它将抛出此错误。