Support Topics Documentation Slack YouTube Blog

PUSH Mission - User authentication is failing

Mission: LET’S PUSH
Task: Send a push notification from console with smart text

This is my code and I can’t understand (or troubleshoot effectively) how to get logins to authenticate, I’ve tried switching it from email to username authentication but regardless I get this error displayed in Toast

“Login Failed Server reported an error. See fault details for additional information.”

package com.apps4u.pushman;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

import com.backendless.Backendless;
import com.backendless.BackendlessUser;
import com.backendless.DeviceRegistration;
import com.backendless.async.callback.AsyncCallback;
import com.backendless.exceptions.BackendlessFault;
import com.backendless.push.DeviceRegistrationResult;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Backendless.setUrl("https://apitest.backendless.com");

        Backendless.initApp(this, "7A19C773-699A-AC1C-FFE7-693920E7A200", "B873FD95-D6EA-4998-99DA-9A2070475950");

        final Context context =  this;
        final AsyncCallback<DeviceRegistrationResult> registerDeviceCallback = new AsyncCallback<DeviceRegistrationResult>() {
            @Override
            public void handleResponse(DeviceRegistrationResult response) {
                Toast.makeText(context,  "Device Registered!",
                        Toast.LENGTH_LONG).show();
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                    Toast.makeText(context,  "Device FAILED!" + fault.getMessage(),
                            Toast.LENGTH_LONG).show();
            }
        };


        //List<String> channels = new ArrayList<String>();
        //channels.add( "default" );
        //Backendless.Messaging.registerDevice(channels, new AsyncCallback<DeviceRegistrationResult>() {
            //@Override
            //public void handleResponse(DeviceRegistrationResult response) {
                //Toast.makeText(getApplicationContext(),  "Device Registered!",
                //        Toast.LENGTH_LONG).show();
            //}

            //@Override
            //public void handleFault(BackendlessFault fault) {
            //    Toast.makeText(getApplicationContext(),  "Device FAILED!",
            //            Toast.LENGTH_LONG).show();
            //}

        AsyncCallback<BackendlessUser> loginCallback = new AsyncCallback<BackendlessUser>() {
            @Override
            public void handleResponse(BackendlessUser response) {
                List<String> channels = new ArrayList<String>();
                channels.add( "default" );
                Backendless.Messaging.registerDevice(channels, registerDeviceCallback );
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                Toast.makeText( context,  "Login Failed " + fault.getMessage(),
                        Toast.LENGTH_LONG).show();
            }
        };


        Backendless.UserService.login(
                "Graham",
                "1234",
                loginCallback);


    }
}

Noticed this in the logcat

2020-10-23 11:53:48.584 12689-12689/com.apps4u.pushman E/BackendlessFCMService: Can not refresh device token on Backendless. Server reported an error. See fault details for additional information

Hi @Graham_Reddie

It’s a little bit confusing. Do you want to login the user or register the device for push notifications?

One more question: why did you set that url?

Backendless.setUrl("https://apitest.backendless.com");

Hey @Maksym_Khobotin2,

I want to do both, and I’d copied the code from this video

This is the task I’m trying to complete…

Thanks for you help btw :blush:

1 Like

This url is for dev purposes. You should remove it. Try to run the project without that line of code.

Yep that was it thank you.

Awesome! Good luck with the missions :wink:

You have the patience of a Saint :slight_smile: thank you…

1 Like