When I get successful callback from loginWithGooglePlusSdk (with argument stayLoggedIn set to true) I’m calling some custom event from an Android client in this way:
Backendless.Events.dispatch("createGroup", args, new AsyncCallback<Map>() {...})
At a server side, I would like to get an instance of a current user but the method Backendless.UserService.CurrentUser() always returns null value. But if I call Backendless.UserService.findById(context.getUserId()) then the instance of user is provided.
Business logic:
@BackendlessEvent("createGroup")
public class GroupCreationEventHandler extends CustomEventHandler {
@Override
public Map handleEvent(final RunnerContext context, Map eventArgs) {
try {
BackendlessUser currentUser = Backendless.UserService.CurrentUser(); // This is returning null value
BackendlessUser user = Backendless.UserService.findById(context.getUserId()); // This returns instance of current user
} catch(Exception e) {
e.printStackTrace();
}
HashMap<String, String> bla = new HashMap<String, String>();
bla.put("key", "behemoth");
return bla;
}
}
I would like to know why is this happening?