How to Register App Users With the User Registration API

by on September 1, 2019

We’re continuing our Backendless Recipe series. In this post, we will review the user registration API (see the API documentation for Android, iOS, JavaScriptREST). The User Registration API is likely one of the first APIs you work with when you start with Backendless. The API handles the process of registering a user with an application so they can log in and use the application.

The Android and iOS APIs use the built-in BackendlessUser class, while the JS SDK uses the Backendless.User class, and, of course, it is a JSON object with REST. The code below creates a user, sets the userid/password as well as an additional phoneNumber registration property, and calls the backend. Please note that in mobile applications, you need to use the asynchronous version of the API.

    import android.content.Context;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.ProgressBar;
    import android.widget.Toast;
    import com.backendless.Backendless;
    import com.backendless.BackendlessUser;
    import com.backendless.async.callback.AsyncCallback;
    import com.backendless.exceptions.BackendlessFault;
    public class MainActivity extends AppCompatActivity {
        private static String APPID = "YOUR-APP-ID";
        private static String APIKEY = "YOUR-ANDROID-API-KEY";
        protected void onCreate(Bundle savedInstanceState) {
            Backendless.initApp(this, APPID, APIKEY );
            BackendlessUser user = new BackendlessUser();
            user.setEmail( "" );
            user.setPassword( "sp1dey" );
            user.setProperty( "name", "Green Goblin" );
            user.setProperty( "phoneNumber", "212-555-1212" );
            final ProgressBar progressBar = findViewById(;
            Backendless.UserService.register(user, new AsyncCallback<BackendlessUser>() {
                public void handleResponse(BackendlessUser response) {
                    Toast.makeText(getContext(), "User has been registered", Toast.LENGTH_LONG).show();
                public void handleFault(BackendlessFault fault) {
                    Toast.makeText(getContext(), fault.getMessage(), Toast.LENGTH_LONG).show();
        public Context getContext() {
            return this;

    val user = BackendlessUser() = ""
    user.password = "sp1dey"
    user.setProperty("name", "Green Goblin")
    user.setProperty("phoneNumber", "212-555-1212")
    Backendless.UserService.register(user, object : AsyncCallback<BackendlessUser> {
       override fun handleResponse(registeredUser: BackendlessUser?) {
           Log.i(TAG, "User has been registered")
       override fun handleFault(fault: BackendlessFault?) {
           Log.e(TAG, fault?.message)

    BackendlessUser *user = [BackendlessUser new]; = @"";
    user.password = @"sp1dey";
    [user addPropertyWithPropertyName:@"phoneNumber" propertyValue:@"214-555-1212"];
    [Backendless.shared.userService registerUserWithUser:user responseHandler:^(BackendlessUser *registeredUser) {
        NSLog(@"User has been registered: %@", registeredUser);
    } errorHandler:^(Fault *fault) {
        NSLog(@"Error: %@", fault.message);

    let user = BackendlessUser() = ""
    user.password = "sp1dey"
    user.addProperty(propertyName: "phoneNumber", propertyValue: "214-555-1212")
    Backendless.shared.userService.registerUser(user: user, responseHandler: { registeredUser in
        print("User has been registered: \(registeredUser)")
    }, errorHandler: { fault in
        print("Error: \(fault.message ?? "")")

    const Backendless = require('backendless')
     Or use `import Backendless from 'backendless'` for client side.
     If you don't use npm or yarn to install modules, you can add the following line
     <script src="//"></script>
     to your index.html file and use the global Backendless variable.
    Backendless.initApp('YOUR_APP_ID', 'YOUR_JS_API_KEY')
    const onSuccess = user => {
      console.log('User has been registered:\n', user)
    const onError = error => {
      console.error('Server reported an error: ', error.message)
      console.error('error code: ', error.code)
      console.error('http status: ', error.status)
    const user = new Backendless.User() = ''
    user.password = 'sp1dey' = 'Green Goblin'
    user.phoneNumber = '212-555-1212'

    BackendlessUser user = BackendlessUser(); = "";
    user.password = "sp1dey";
    user.setProperty("name", "Green Goblin");
    user.setProperty("phoneNumber", "212-555-1212");
    Backendless.UserService.register(user).then((registeredUser) => print("User has been registered"));

    Once you run the code, the user is registered and should be able to log in (unless your Backendless backend requires them to confirm the email address, which is another feature we offer). You can see the registered users in Backendless Console:

    1. Navigate to Backendless Console, select your app and click the Data icon.
    2. The Users table should be selected by default. The users will show up there:


    Leave a Reply