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);
}
}