我是一年有经验的人在android。我有一个项目在应用程序上实现视频聊天。 我使用以下projetct代码作为参考。
https://github.com/QuickBlox/quickblox-android-sdk/tree/master/sample-videochat
但它不包含以编程方式创建的用户(注册)。
所以我在注册会话中加入了以下代码。
private void RegisterUser(){
progressDialog.show();
final QBUser user = new QBUser("username", "password");
user.setFacebookId("123456");
user.setTwitterId("123456");
user.setEmail("info@domain.com");
user.setFullName("Full Name");
user.setPhone("+911234234456");
StringifyArrayList<String> tags = new StringifyArrayList<String>();
tags.add("car");
tags.add("man");
user.setTags(tags);
user.setWebsite("www.domain.com");
QBUsers.signUp(user, new QBCallbackImpl() {
@Override
public void onComplete(Result result) {
progressDialog.dismiss();
if (result.isSuccess()) {
QBUserResult qbUserResult = (QBUserResult) result;
Log.d("Registration was successful","user: " + qbUserResult.getUser().toString());
} else {
Log.e("Errors",result.getErrors().toString());
}
}
}
);
}
但在执行RegisterUser()
时我收到以下错误
08-19 10:46:56.696: E/NativeCrypto(9664): ssl=0x52949540 cert_verify_callback x509_store_ctx=0x52ea7ab8 arg=0x0
08-19 10:46:56.697: E/NativeCrypto(9664): ssl=0x52949540 cert_verify_callback calling verifyCertificateChain authMethod=DHE_RSA
08-19 10:46:57.443: E/Errors(9664): [Token is required]
请有人给我一个解决方案,或者在QuickBlox上以编程方式注册代码......?
答案 0 :(得分:1)
启动您的应用程序时,在您注册后首先使用您的quickblox帐户验证您的应用程序。 1.在你的应用程序中创建应用程序类。
public class VideoChatApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
QBSettings.getInstance().fastConfigInit(Constant.APP_ID,
Constant.AUTH_KEY, Constant.AUTH_SECRET);
}
}
2在清单文件中定义您的应用程序类
<application
android:name=".VideoChatApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Signup"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity></application>
3.注册用户
QBAuth.createSession(new QBEntityCallback<QBSession>() {
@Override
public void onError(List<String> arg0) {
}
@Override
public void onSuccess() {
System.out.println("session is created");
}
@Override
public void onSuccess(QBSession arg0, Bundle arg1) {
// signup code you must signup first
final QBUser quser = new QBUser(
"Username","password");
quser.setFullName("fullname");
QBUsers.signUp(quser,
new QBEntityCallbackImpl<QBUser>() {
@Override
public void onSuccess(QBUser quser,
Bundle args) {
//login success
}
@Override
public void onError(
List<String> errors) {
Toast.makeText(
getApplicationContext(),
"call onError"
+ errors.toString(),
Toast.LENGTH_SHORT)
.show();
if (errors.toString()
.equals("")) {
}
}
});
}
});