Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Truecaller android sdk Error Code 3

Tags:

java

android

sdk

I am trying to implement the Truecaller android-SDK for Sign In/Sign Up on one of my personal app. I received the partner key from truecaller to implement it in my app. Error occurs on pressing 'Autofill with truecaller' returns the 'Error Code 3' on 'trueError.getErrorType( )' in 'public void onFailureProfileShared()'. I can't seem to find the method for describing the error. Does anyone happen to know to fix this error?

My implementation:

public class auth extends AppCompatActivity implements ITrueCallback{

private TrueButton truebutton = null;
private TrueClient trueClient = null;

private String mTruecallerRequestNonce = null;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_auth);
    truebutton = (TrueButton) findViewById(R.id.com_truecaller_android_sdk_truebutton);

    boolean isUsable = truebutton.isUsable();
    if(isUsable) {
        trueClient = new TrueClient(auth.this, auth.this);
        truebutton.setTrueClient(trueClient);
    }
    else {
        truebutton.setVisibility(View.GONE);
    }

    truebutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            trueClient.getTruecallerUserProfile(auth.this);
        }
    });
}


@Override
protected void onResume() {
    mTruecallerRequestNonce = trueClient.generateRequestNonce();
    super.onResume();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(trueClient!=null && trueClient.onActivityResult(requestCode, resultCode, data)) {
        return;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

@Override
public void onSuccesProfileShared(@NonNull TrueProfile trueProfile) {
    Toast.makeText(auth.this, trueProfile.firstName + " " + trueProfile.lastName, Toast.LENGTH_LONG).show();
}

@Override
public void onFailureProfileShared(@NonNull TrueError trueError) {
    Log.e("error code", trueError.getErrorType() + " ");
}
}
like image 654
VipiN Negi Avatar asked Jul 28 '17 09:07

VipiN Negi


People also ask

Is Truecaller SDK free?

Is Truecaller SDK free to use ? Yes - Truecaller SDK is 100% free to use, no user verification limits whatsoever.

How can I get my Truecaller API key?

To ensure the authenticity of interactions between your web app and Truecaller, you need to generate an app key [ partner key ] from Truecaller developer account ( https://developer.truecaller.com/login ) by adding your app name, domain and a callback URL.

Does Truecaller have an API?

Would your business or idea profit from using the Truecaller API? Sign up for our API access program now! We are currently working on it for developers. If you want to get notified when it's ready then enter your details in the link below.

How can I verify my mobile number in Truecaller?

You can start the process by associating your profile with a Facebook account where the name matches your name in Truecaller. Once the system has enough proof that your name is accurate, the system will automatically assign the Verified badge to you. Roopini is the author of this solution article.


2 Answers

Here is the list of all of the TrueCaller error codes:

ERROR_TYPE_INTERNAL = 0;
ERROR_TYPE_NETWORK = 1;
ERROR_TYPE_USER_DENIED = 2;
ERROR_TYPE_UNAUTHORIZED_PARTNER = 3;
ERROR_TYPE_UNAUTHORIZED_USER = 4;
ERROR_TYPE_TRUECALLER_CLOSED_UNEXPECTEDLY = 5;
ERROR_TYPE_TRUESDK_TOO_OLD = 6;
ERROR_TYPE_POSSIBLE_REQ_CODE_COLLISION = 7;
ERROR_TYPE_RESPONSE_SIGNATURE_MISSMATCH = 8;
ERROR_TYPE_REQUEST_NONCE_MISSMATCH = 9;

These codes are static members of the TrueError class, so you could access them like so:

switch (trueError.getErrorType()) {

    case TrueError.ERROR_TYPE_INTERNAL:
        // do something
        break;
    case TrueError.ERROR_TYPE_NETWORK:
        // do something else
        break;
    // etc.
}

In your case the error you are getting is error code 3, ERROR_TYPE_UNAUTHORIZED_PARTNER. Have you made sure to get the partner key, and to add this line in your AndroidManifest.xml?

<meta-data android:name="com.truecaller.android.sdk.PartnerKey" android:value="YOUR_PARTNER_KEY_HERE"/>
like image 91
qualverse Avatar answered Sep 29 '22 10:09

qualverse


Finally got it working with helps. Thanks to @Sayan for taking me one step closer and @qualverse to understanding the 'Error-Codes'.

Truecaller requires SHA1 from you and provide you back with PartnerKey. What I figured out is that it doesn't matter if your app is release or debug. If PartnerKey is generated with debug SHA1 key then you must build app with debug variant and if PartnerKey is generated with released SHA1 then build app with released variant.

Below screenshot will help in understanding the key type:

enter image description here

One can make entries for both variant on Truecaller dashboard to work on both variant simultaneously. Always make sure to signing the release variant properly.

like image 43
VipiN Negi Avatar answered Sep 29 '22 10:09

VipiN Negi