Unable to signUp a new user in quickblox - java

I have been trying to add a new user to quickblox referring to the code provided in the sample-chat provided for android.
I am using the following code.
Authenticate using APP_ID,AUTH_ID and SECRET_ID.
QBSettings.getInstance().fastConfigInit(APP_ID, AUTH_KEY, AUTH_SECRET);
Create an application session
QBAuth.createSession(new QBEntityCallbackImpl<QBSession>() {
#Override
public void onSuccess(QBSession qbSession, Bundle bundle) {
getAllUser();
}
#Override
public void onError(List<String> errors) {
// print errors that came from server
DialogUtils.showLong(context, errors.get(0));
progressBar.setVisibility(View.INVISIBLE);
}
});
}
//Sign up a new user
// Register new user
final QBUser user = new QBUser("userlogin", "userpassword");
QBUsers.signUp(user, new QBEntityCallbackImpl<QBUser>() {
#Override
public void onSuccess(QBUser user, Bundle args) {
// success
}
#Override
public void onError(List<String> errors) {
// error
}
});
User signup is not working.I am able to login using an already registered user via quickblox administration panel.
I want to create a new user as soon as I login and create chat service with the same login.I am new to quickblox and java any help will be appreciated.

The right way is to call QBUsers.signUp inside CreateSession onSuccess block
Because these QuickBlox queries are asynchronous

instead of using "QbAuth.createSession", use "QBUsers.Signup" for registering a new user.
This is because the former method is used for creating session, which is only possible if you have a user logged into the quickblox.
So, use the latter method and register a user into the quickblox first.
If you are still facing the issue, then just check your "Auth Keys", "Auth Secret" in your application, if they are correct.

Related

Carrier custom application

I need to create an Android application to set carrier configuration(VoLte e.g.). The application should fetch configs from our Back-End and apply them on the phone.
In Android documentation I found the following article: This article says, that I can create my own application and override CarrierService.
public class SampleCarrierConfigService extends CarrierService {
private static final String TAG = "SampleCarrierConfigService";
public SampleCarrierConfigService() {
Log.d(TAG, "Service created");
}
#Override
public PersistableBundle onLoadConfig(CarrierIdentifier id) {
Log.d(TAG, "Config being fetched");
PersistableBundle config = new PersistableBundle();
config.putBoolean(
CarrierConfigManager.KEY_CARRIER_VOLTE_AVAILABLE_BOOL, true);
config.putBoolean(
CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL, false);
config.putInt(CarrierConfigManager.KEY_VOLTE_REPLACEMENT_RAT_INT, 6);
// Check CarrierIdentifier and add more config if needed…
return config;
}
}
I created an app with this service, but the method onLoadConfig(CarrierIdentifier id) is never called by the system.
So what I want from the system to call my overridden method, not system's. What should I do?
I found your question when researching how to do something similar.
In the article you linked it says:
The carrier app in question must be signed with the same certificate found on the SIM card, as documented in UICC Carrier Privileges.
Since we can't get the certificate from your carrier (they will never give it to you) I think we can't implement our own flavour sadly :-(

Initialize a Stripe Object in new Android Studio

Currently, I am working to create a Stripe payment method in an Android Studio App. This will involve a credit card object which will be stored by Stripe into my Firestore DB. Unfortunately, one of the lines in the tutorial that I have used is outdated since it uses getContext() without a view.
Background on Stripe:
https://www.youtube.com/watch?v=JeyxolsJ3aE
Background on Firestore:
https://firebase.google.com/docs/firestore
Here is the link to the tutorial that I am following:
https://stripe.com/docs/mobile/android
Unfortunately, I have not had much luck finding a tutorial that is knew, uses the same format and does not use getContext().
I have already completed all steps up to inserting the line:
final Stripe stripe = new Stripe(
getContext(),
"pk_test_TYooMQauvdEDq54NiTphI7jx"
);
In my version of Android Studio (3.4.1), it seems getContext() cannot be used without a View (shows up as red). As a result, I have tried to substitute a variety of commands. However, they all produce the same crash with message "Invalid Content Provider: null". I believe that "Content Provider" refers to the Context passed in.
I should mention that the Stripe object is created within an On-Click listener. Further, I know that the "pk_test" key is correct and I have tested other valid ids also to no avail. Further, through tests with commenting out code, I am certain that this is the line producing my error.
My theory is that the context is being rejected by Stripe or Firebase. This is because the Stripe Context is known as a "Stripe Provider" (https://lh3.googleusercontent.com/-ByYW3X0ua38/XQ_kRpmddLI/AAAAAAAAAAI/YfhjxSJ9iO0aJwZ8RtANeCXKXyYglWX1QCK8BGAs/s0/2019-06-23.png)
Some of the commands that I have tried are:
getContext() (not recognized)
getApplicationContext()
getBaseContext()
this
this.getApplicationContext()
ClassName.this.getApplicationContext()
ClassName.this.getBaseContext()
Submit.getContext()
WrappingLayoutView.getContext()
I have also tried to capture the Context in OnCreate above the OnClick listener in a variable.
Since none of these are working, I am rather stuck as to what to do.
Here is my Java Code:
public class AddCardActivity extends AppCompatActivity {
private Button submit;
public Context mContext;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_card);
init();
mContext = this.getApplicationContext();
//Not working
/**View mV=findViewById(R.id.myLView);
mContext=mV.getContext();**/
submit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
//Use stripe to add new payment to firestore
//This line causes a crash
Stripe stripe = new Stripe(submit.getContext(),
"pk_test_t6NMvJpXDEZd3eOn5SU4y6DA"
);
// The Card class will normalize the card number
final Card card = Card.create("4242-4242-4242-4242", 12, 2020, "123");
//Update this with more useful error messages
if (card == null) {
Toast.makeText(getApplicationContext(), "Invalid Card!", Toast.LENGTH_LONG).show();
}
card.validateNumber();
card.validateCVC();
stripe.createToken(
card,
new TokenCallback() {
public void onSuccess(#NonNull Token token) {
// Send token to your server
}
public void onError(#NonNull Exception error) {
// Show localized error message
Toast.makeText(getApplicationContext(), "Invalid Card!", Toast.LENGTH_LONG).show();
}
}
);
}
});
}
private void init() {
submit = (Button) findViewById(R.id.addCardActivityButton);
}
Here you go:
Token token = null;
final Card card = new Card(cardNumber, month, year, cvc);
final Stripe stripe = new Stripe(getApplicationContext());
try {
token = stripe.createTokenSynchronous(card, "pk_test_TYooMQauvdEDq54NiTphI7jx");
} catch (StripeException stripeEx) {
errorMessage = stripeEx.getLocalizedMessage();
}

Stuck and unable to sign in after deleting google play games data

I'm using Google Play Services for my libgdx game. I created some dummy achievements to test and later wanted to remove them. On my phone I went to Google Play Games -> Settings -> Delete Play Games Data -> Deleted data from my game.
After going back into my game, I noticed that the game thought I was still signed in. I use the following code to check if a user is signed in:
#Override
public boolean isSignedIn(){
return GoogleSignIn.getLastSignedInAccount(androidLauncher) != null;
}
If the user is not signed in, I try to sign them in silently
private void signInSilently() {
signedInClient.silentSignIn().addOnCompleteListener(androidLauncher,
new OnCompleteListener<GoogleSignInAccount>() {
#Override
public void onComplete(#NonNull Task<GoogleSignInAccount> task) {
if (task.isSuccessful()) {
signedInAccount = task.getResult();
}
}
});
}
If I can't sign them in silenty. I create a new intent and have them manually sign in and give access to the app:
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
signedInAccount = result.getSignInAccount();
showSignedInDialog();
}
The problem is, after deleting the Play Games Data, my method isSignedIn is always returning true. However, when I try to do something like display achievements, I get the following error:
com.google.android.gms.common.api.ApiException: 4: The user must be signed in to make this API call.
Code for showing achievements:
#Override
public void showAchievements(){
androidLauncher.runOnUiThread(new Runnable() {
#Override
public void run() {
if (isSignedIn()) {
loadingView.showLoadingView();
Games.getAchievementsClient(androidLauncher, signedInAccount)
.getAchievementsIntent()
.addOnSuccessListener(new OnSuccessListener<Intent>() {
#Override
public void onSuccess(Intent intent) {
androidLauncher
.startActivityForResult(intent, RC_ACHIEVEMENT_UI);
}
})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Logger.error(e);
}
})
}
}
});
}
I'm curious as to why this is happening. According to the documentation, my isSignedIn method should be working correctly. However, because I'm getting the error that I'm getting when I actually try to make an API call, it appears that the method is not working. I can only assume that all of this is stemming from me deleting my Play Games Data as everything worked fine up until that point.
Something else I want to note - I tried having my isSignedIn method return false to force a silent sign in. My silent sign in returned the following error:
com.google.android.gms.common.api.ApiException: 8: 8:
I did a bit of research and found a bug report. It looks like a status code of 8 is an Internal Error. Google at least seems to be aware of the issue.
Update: After having my isSignedIn method return false, and after disabling my silent sign in, I forced a manual sign in. After forcing the manual sign in, and signing in, it now works. However, I won't be able to do that for users if they run into the same issue. They would be stuck as the isSignedIn method seems to always return true after deleting the Play Games Data.
I had a similar issue and what worked for me was enabling the Google Drive API for my project. Not sure why this worked, but it did.
Go to https://console.developers.google.com/apis, then open the "Library" menu option. From there, search for "Drive" and click on the "Google Drive API" item. You should then see an enable button.

Azure Mobile Services Android Error

I'm doing an android app and trying to integrate social login into the application using Azure Mobile Services.
public class SocialLogin extends Activity implements UserAuthenticationCallback {
#Override
protected void onCreate(Bundle savedInstanceState) {
// on create code
}
// All the code
#Override
public void onCompleted(MobileServiceUser user, Exception exception, ServiceFilterResponse response) {
if (exception == null) {
//Take user to the logged in view
cacheUserToken(user);
} else {
Log.e("SocialLogin", "User did not login successfully");
}
}
}
I'm getting two errors because of the onCompleted method.
Error:(176, 5) error: method does not override or implement a method from a supertype
Error:(37, 8) error: SocialLogin is not abstract and does not override abstract method onCompleted(MobileServiceUser,Exception,ServiceFilterResponse) in UserAuthenticationCallback
Edit: Fixed the problem by deleting away the .jar file in my lib.
Per my understanding, 'UserAuthenticationCallback' is not an interface since many of samples are coding like this:
MobileServiceClient mClient = new MobileServiceClient(
"MobileServiceUrl",
"AppKey",
this).withFilter(new ProgressFilter());
mClient.login(MobileServiceAuthenticationProvider.MicrosoftAccount,
new UserAuthenticationCallback() {
#Override
public void onCompleted(MobileServiceUser user,
Exception exception, ServiceFilterResponse response) {
synchronized(mAuthenticationLock)
{
if (exception == null) {
cacheUserToken(mClient.getCurrentUser());
} else {
createAndShowDialog(exception.getMessage(), "Login Error");
}
}
}
});
Since it is not an interface, we cannot implement it as you did. You can either create a class that inherits UserAuthenticationCallback (but the class cannot inherit Activity as we can only inherit one class), or simply create a new instance of UserAuthenticationCallback like the code in the sample.
Also, I'd like to suggest you to check https://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-get-started-users/ and https://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-get-started-data/ for a completed sample of how to add authentication to your Mobile Services Android app.

GWTP: Reveal unauthorizedPlaceRequest after successful login

When a user is not logged in and navigates to !/someRestrictedPlace he is is navigated due to the LoggedInGatekeeper to the login page. After successful login I want that the user will be redirected to !/someRestrictedPlace
What I did is create a DefaultPlaceManagerImpl extends PlaceManagerImpl then I use the following method:
#Override
public void revealUnauthorizedPlace(String unauthorizedHistoryToken) {
revealPlace(unauthorizedPlaceRequest, true);
}
Is this the way to do it, because the comments in DefaultPlaceManage says that this would create an infinite loop?
Here is my solution.
In my PlaceManager I redirect to LoginPresenter but by #someRestrictedPlace/login
public void revealUnauthorizedPlace(String unauthorizedHistoryToken)
{
revealRelativePlace(new PlaceRequest(NameTokens.login));
}
In my LoginPresenter after successful login
if (placeManager.getHierarchyDepth() > 1)
placeManager.revealRelativePlace(-1);
else
placeManager.revealPlace(...some default place..., true);

Categories