Updating users

10 posts, 0 answers
  1. Mark
    Mark avatar
    11 posts
    Member since:
    Oct 2015

    Posted 31 Mar Link to this post

    I am trying to update users who registered with faceebook to include their email addresses. i have tried the code in the documentation but i get an incompatible types error.

    public void updateUserById(EverliveApp app, UUID userId, User updateObject) {
        User user = app.workWith().users().getById(userId);
        Log.i("App_name", "Username: " + user.getUsername());
        app.workWith().users().updateById(userId, updateObject).executeSync();
    }

    the error is on the line:       User myUser = app.workWith().users().getMe().executeSync();

     

    User is of type:

    com.telerik.everlive.sdk.core.model.system.user

    And

    app.workWith().users().getMe().executeSync() returns : 

    com.telerik.everlive.sdk.core.facades.read.getByIdFacades

  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 01 Apr Link to this post

    Hello Mark,

    You can obtain the Users in the same way as other data types (as shown here). For example:

    RequestResult<User> myUser = app.workWith().users(User.class).getById(userId).executeSync();

    We will update the documentation for reading users with the appropriate code snippet.

    Let me know if this works for you.

    Regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  3. Anne Sophie
    Anne Sophie avatar
    16 posts
    Member since:
    Oct 2015

    Posted 01 Apr in reply to Anton Dobrev Link to this post

    but this does not return a User object and i cant access its attributes

    like in the log in the original post "user.getUsername()" getUsername() is unresolved

  4. Anne Sophie
    Anne Sophie avatar
    16 posts
    Member since:
    Oct 2015

    Posted 01 Apr in reply to Anne Sophie Link to this post

    disregard the last post
  5. Mark
    Mark avatar
    11 posts
    Member since:
    Oct 2015

    Posted 04 Apr in reply to Anton Dobrev Link to this post

    i was also having a different problem with this it appears the user is not getting loggid in after loginwithfacebook is called. Why is this?

    app.everliveApp.workWith().authentication().loginWithFacebook(facebookToken).executeAsync(new RequestResultCallbackAction() {
    @Override
    public void invoke(RequestResult requestResult) {
      Log.d("TAG","Login To Telerik With Facebook Called!");
      if (requestResult.getSuccess()) {
             Log.i("TAG -- ", loginResultFacebook.getId().toString()); // prints 00000000-0000-0000-0000-000000000000
      //getUsername(app.everliveApp,loginResultFacebook.getId());
        Intent i = new Intent(LoginActivity.this, MainActivity.class);
      startActivity(i);
      finish();
      }
      }
    });
  6. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 05 Apr Link to this post

    Hi Mark,

    Usually, the login method will only return the access token of the logged in user as returned from the server. To get the user account properties for the current user utilize the getMe method. For example:

    everliveApp.workWith().authentication().loginWithFacebook(facebookToken).executeAsync(new RequestResultCallbackAction() {
               @Override
               public void invoke(RequestResult requestResult) {
     
                   if(requestResult.getSuccess()) {
                       // get the current user
                       everliveApp.workWith().users().getMe().executeAsync(
                               new RequestResultCallbackAction() {
                                   @Override
                                   public void invoke(RequestResult requestResult) {
     
                                       if (requestResult.getSuccess()) {
                                           // the user is logged in
                                          // access the user properties
                                         User myUser = (User) requestResult.getValue();
                                           myUser.getId();
     
                                       } else {
                                           // the user is not logged in
                                       }
                                   }
                               }
                       );
                   }
               }
           });

    I hope that this works for you.

    Regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  7. Anne Sophie
    Anne Sophie avatar
    16 posts
    Member since:
    Oct 2015

    Posted 05 Apr in reply to Anton Dobrev Link to this post

    Do I need the call this every time i create data objects? as now when i create any data object is is created in the back end but the created/modified by fields are empty. Also are there any issues with the platform as any user or data created from an android device appears to be created (no errors) but cant be viewed @ platform.telerik.com. i can create users and login with the credentials but they don't appear on the site. on IOS i cant create a user. i get returned the provided access token is invalid or has expired , but this problem went away by uninstalling the app (just ios).
  8. Mark
    Mark avatar
    11 posts
    Member since:
    Oct 2015

    Posted 05 Apr in reply to Anne Sophie Link to this post

    Sorry @Anton Dobrev  as you may have gathered i am signed in to 2 platform accounts in different browsers.

     

    Mark (Actually) said:Do I need the call this every time i create data objects? as now when i create any data object is is created in the back end but the created/modified by fields are empty. Also are there any issues with the platform as any user or data created from an android device appears to be created (no errors) but cant be viewed @ platform.telerik.com. i can create users and login with the credentials but they don't appear on the site. on IOS i cant create a user. i get returned the provided access token is invalid or has expired , but this problem went away by uninstalling the app (just ios).

  9. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 07 Apr Link to this post

    Hello Mark,

    As to your questions.

    Do I need the call this every time i create data objects? as now when i create any data object is is created in the back end but the created/modified by fields are empty.

    It may be a good idea to check if a user is logged in (users.getMe())   prior to making any application critical operations with the server. This way you ensure that the user is logged in and the items created in the database will be set their system fields.

    For more info on the system fields and how they are set see support thread 1023909.

    For more info on managing the state of the current user see here.

    Also are there any issues with the platform as any user or data created from an android device appears to be created (no errors) but cant be viewed @ platform.telerik.com. i can create users and login with the credentials but they don't appear on the site.

    This sounds like a really peculiar behavior. To provide you with a resolution:

    - Can you confirm that you are exploring the data in the portal for the same project as its App ID in the client app?

    - Can you show some screenshots or provide an API key (App Id) to check on our side?

    - What happens if you issue a GET request to the Users endpoint as explained here?

    - Can you create a data item from the portal?

     on IOS i cant create a user. i get returned the provided access token is invalid or has expired , but this problem went away by uninstalling the app (just ios).

    This error means that there is a logged in user in the app but the user access token expired or is no longer valid. Please refer to this forum thread for more info.

    Let me know if this works for you.

    Regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  10. Mark
    Mark avatar
    11 posts
    Member since:
    Oct 2015

    Posted 07 Apr in reply to Anton Dobrev Link to this post

    Thank you for your reply. All issues have been solved. On the peculiar behavior, my colleague changed the app id in the wrong project which meant it was working on the device but the data was going to the wrong app on the back end.
Back to Top