QuickBlox / q-municate-android

Qmunicate Android chat application
MIT License
254 stars 197 forks source link

How to update my fullName and webSite? #240

Closed iman2420 closed 7 years ago

iman2420 commented 7 years ago

I want to update my profile from dashboard by Android code.

I try to updateUser:

                         `QBUsers.getUserByLogin(user_unique_id).performAsync(new QBEntityCallback<QBUser>() {

                                @Override
                                public void onSuccess(QBUser qbUser, Bundle bundle) {

                                    // user is registered

                                    Log.e(TAG, "getUserByLogin onSuccess " + qbUser.getLogin());

                                     qbUser.setFullName(nick_name);

                                     qbUser.setEmail(email);

                                    QBUsers.updateUser(qbUser).performAsync(new QBEntityCallback<QBUser>() {
                                        @Override
                                        public void onSuccess(QBUser qbUser, Bundle bundle) {
                                            Log.e(TAG, "updateUser onSuccess " + qbUser.getLogin());
                                        }

                                        @Override
                                        public void onError(QBResponseException e) {
                                            Log.e(TAG, "updateUser onError " + e.getMessage());
                                            //onError base You are not owner of this object
                                        }
                                    });
                                }

                                @Override
                                public void onError(QBResponseException e) {
                                    Log.e(TAG, "getUserByLogin onError " + e.getMessage());

                                }
                            });`

but i got this error in updateUser method:

onError base You are not owner of this object

tatanka987 commented 7 years ago

you can update only current user or you need login in android app with your app administrator's credentials (account owner) and update other user

iman2420 commented 7 years ago

@tatanka987 I know it. How to do it? show me an example.

tatanka987 commented 7 years ago

for example, I created QB account with login "tatankaxxxxxxx@xxxxxxx.com" and password "****". Then I call QBUsers.signIn(new QBUser("tatankaxxxxxxx@xxxxxxx.com", "************")).perform();

then I prepared user for update

QBUser userForUpdate = new QBUser();
userForUpdate.setId(6655786);
userForUpdate.setFullName("Name after Update");

Then I called next code for update needed user: QBUsers.updateUser(userForUpdate).perform();