How to validate multiple purchase transactions with Android AppsFlyer SDK - android

I am having an issue with AppsFlyer Android SDK AppsFlyerInAppPurchaseValidatorListener class.
AppsFlyerLib.getInstance().registerValidatorListener(this,new
AppsFlyerInAppPurchaseValidatorListener() {
public void onValidateInApp() {
Log.d(TAG, "Purchase validated successfully");
}
public void onValidateInAppFailure(String error) {
Log.d(TAG, "onValidateInAppFailure called: " + error);
}
});
Currently there is no way to detect which particular purchase transaction was successful with this listener. So for example, if I am validating multiple purchase transactions from a Google Billing Client queryPurchasesAsync call. This listener will not tell me which specific purchase transaction was successful or failed.
The closest solution to this that I found was at:
AppsFlyerAndroidWrapper.java
public static void validateAndTrackInAppPurchase (String publicKey, String signature, String purchaseData, String price, String currency, HashMap<String, String> additionalParameters, String objectName)
{
AppsFlyerLib.getInstance().validateAndLogInAppPurchase(UnityPlayer.currentActivity,
publicKey, signature, purchaseData, price, currency, additionalParameters);
if (objectName != null)
{
initInAppPurchaseValidatorListener(objectName);
}
}
public static void initInAppPurchaseValidatorListener(final String objectName)
{
AppsFlyerLib.getInstance().registerValidatorListener(UnityPlayer.currentActivity, new
AppsFlyerInAppPurchaseValidatorListener()
{
#Override
public void onValidateInApp() {
if(objectName != null){
UnityPlayer.UnitySendMessage(objectName, VALIDATE_CALLBACK, "Validate
success");
}
}
#Override
public void onValidateInAppFailure(String error) {
if(objectName != null){
UnityPlayer.UnitySendMessage(objectName, VALIDATE_ERROR_CALLBACK, error);
}
}
});
}
Here it looks like they instantiate a new validator listener for each call to validateAndLogInAppPurchase. However, will that not just get rid of the previous validator listener that was instantiated? To me it looks like you can only register ONE validator listener at a time with AppsFlyer. There is no way to tie a particular validator listener to a specific validateAndLogInAppPurchase call. I've searched high and low and have not been able to find a definitive answer to this question so any pointers anyone has would be greatly appreciated.
Thanks
I have searched through github, the Appsflyer Android SDK samples and this particular situation is never addressed. In particular there are no Android SDK samples that tackle this issue so it may be that support for multiple transaction validations is not supported by the Appsflyer Android SDK.

Related

Azure AD B2C Token Expiry MSAL in Native Android

I was integrating azure adb2c on my native android app using MSAL. My token expiry is set to 60minutes in the portal. Currently I'm calling the acquireTokenSilentAsync each time the app launches in order to make sure access token is not expired. But is there any way to avoid calling acquireTokenSilentAsync each time and make the call happens only when the access token expires? This is to make the app load much faster,by avoid calling acquireTokenSilentAsync every time.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.microsoft_azure);
context = MicrosoftAzureActivity.this;
initializeUI();
// Creates a PublicClientApplication object with res/raw/auth_config_single_account.json
PublicClientApplication.createSingleAccountPublicClientApplication(MicrosoftAzureActivity.this,
R.raw.auth_config_single_account,
new IPublicClientApplication.ISingleAccountApplicationCreatedListener() {
#Override
public void onCreated(ISingleAccountPublicClientApplication application) {
/**
* This test app assumes that the app is only going to support one account.
* This requires "account_mode" : "SINGLE" in the config json file.
**/
loadAccount();
}
#Override
public void onError(MsalException exception) {
displayError(exception);
}
});
}
Interactively fetching Token:
mSingleAccountApp.signIn(MicrosoftAzureActivity.this, null, getScopes(), getAuthInteractiveCallback());
Load Account when already token is fetched Interactively and account is already Loaded:
private void loadAccount() {
if (mSingleAccountApp == null) {
Log.d("SKT","Account Not Signed In");
return;
}
Log.d("SKT","Account Not Signed In#1");
mSingleAccountApp.getCurrentAccountAsync(new ISingleAccountPublicClientApplication.CurrentAccountCallback() {
#Override
public void onAccountLoaded(#Nullable IAccount activeAccount) {
// You can use the account data to update your UI or your app database.
mAccount = activeAccount;
if (activeAccount != null) {
Log.d("SKT","Account Already Signed In");
mSingleAccountApp.acquireTokenSilentAsync(getScopes(), B2CConfiguration.getAuthorityFromPolicyName("B2C_1_SignInSignUp"), getAuthSilentCallback());
}
}
#Override
public void onAccountChanged(#Nullable IAccount priorAccount, #Nullable IAccount currentAccount) {
if (currentAccount == null) {
// Perform a cleanup task as the signed-in account changed.
showToastOnSignOut();
}
}
#Override
public void onError(#NonNull MsalException exception) {
displayError(exception);
}
});
}
No, you must call acquireTokenAsync for this, it evaluates whether the token in cache is expired or for a different scope than being requested. If neither is true, MSAL returns the tokens from the cache, it doesn’t make any network calls and should be almost instant. You wouldn’t get any perf advantage by doing anything different as that is the minimum.

Implementation of Android Fingerprint technology

I'm not sure if this is the right place to ask for flow-related question. Do guide me if you're aware of a better section.
I'm currently doing a web based system for multiple organizations, so on my login form, there's 3 simple field:
Company code, such as CNN (so we can have same username, as long as they work in different company)
Username, such as james
Password
Now we are actually studying on the fingerprint authentication technology, on how it could help above.
Our assumption is below:
On our app, we provide user a registration screen, instead of username/password, they tap their thumb on the form, so we can get something, maybe a lengthy random string, which represents the thumbprint, then we pass this code to server, along with his profile, and registration completes.
Above repeats for thousands of our other users.
A user came to our app login screen, we show them a scanner, they put their thumbs on it, we send the retrieved fingerprint code, and send to server for a matching comparison, then we authenticate this user.
But from what we studied, it seems that the fingerprint SDK doesn't works this way, it simply authenticate if the user is the owner of the phone, and it does not provide us a code or something to represents the fingerprint.
Can anyone with experience in developing a working/deployed fingerprint app, share with me how does fingerprint helps in authenticating your user?
Thank you.
you should add this line in your manifest.xml - <uses-feature
android:name="android.hardware.fingerprint"
android:required="false" />
Here is the code sample to show fingerprint dialog and get result from user interaction:
private void showFingerPrintDialog() {
final FingerprintDialogBuilder dialogBuilder = new FingerprintDialogBuilder(ContextInstance)
.setTitle(R.string.fingerprint_dialog_title)
.setSubtitle(R.string.fingerprint_dialog_subtitle)
.setDescription(R.string.fingerprint_dialog_description)
.setNegativeButton(R.string.cancel);
dialogBuilder.show(getSupportFragmentManager(), new AuthenticationCallback() {
#Override
public void fingerprintAuthenticationNotSupported() {
Log.d(TAG, "fingerprintAuthenticationNotSupported: ");
}
#Override
public void hasNoFingerprintEnrolled() {
Log.d(TAG, "hasNoFingerprintEnrolled: ");
}
#Override
public void onAuthenticationError(int errorCode, #Nullable CharSequence errString) {
Log.d(TAG, "onAuthenticationError: ");
}
#Override
public void onAuthenticationHelp(int helpCode, #Nullable CharSequence helpString) {
Log.d(TAG, "onAuthenticationHelp: ");
}
#Override
public void authenticationCanceledByUser() {
Log.d(TAG, "authenticationCanceledByUser: ");
}
#Override
public void onAuthenticationSucceeded() {
Log.d(TAG, "onAuthenticationSucceeded: ");
/*SaveResult in db or preference*/
}
#Override
public void onAuthenticationFailed() {
Log.d(TAG, "onAuthenticationFailed: ");
}
});
}

Checkout Android Billing API getPurchaseHistory method question

Could you help to figure out what I'm doing wrong?
My goal is to obtain an Android subscription purchase history. To make this I using Android-checkout. So far the lib leverage was pretty straightforward. I managed to implement the purchase flow and access using
Inventory.Request
The next step in my business logic was to get a subscription history details.
Here is my code
Billing billing = new Billing(this, new Billing.DefaultConfiguration() {
#Override
public String getPublicKey() {
final Context applicationContext = getApplicationContext();
final Resources resources = applicationContext.getResources();
return resources.getString(R.string.google_play_key);
}
});
billing.connect()
billing.getRequests().isBillingSupported("<productId>")
isBillingSupported returns me BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE (2)
when I try the following
billing.getRequests().getPurchases(<productId>,
null, new RequestListener<Purchases>() {
#Override
public void onSuccess(Purchases result) {
}
#Override
public void onError(int response, Exception e) {
}
});
The error callback method is returned and the error code is BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE (3)
Thanks in advance, probably it's worth getting switched to another library

Getting "User is not authenticated" exception in cognito

I have registered one user using AWS Cognito android SDK. I am login with user on one device and I am able to fetch all the attributes of the user.But when I log in with same user on different device it gives me CognitoNotAuthorizedException (user is not authenticated message) and I am not able to fetch the attributes.
I have checked on Cognito user pool and the user has been registered and confirmed also phone number has been verified.Is there any version specification for getUserDetails() method which I am missing.I also ran signup/login/forgot password functionality on second device and all are working fine except getUserDetail.Below Code I am using for getting user details.
private void getDetails() {
AppHelper.getPool().getUser(mUsername).getDetailsInBackground(detailsHandler);
}
GetDetailsHandler detailsHandler = new GetDetailsHandler() {
#Override
public void onSuccess(CognitoUserDetails cognitoUserDetails) {
AppHelper.setUserDetails(cognitoUserDetails);
}
#Override
public void onFailure(Exception exception) {
showDialogMessage(getString(R.string.could_not_fetch_user_data), AppHelper.formatException(exception), true);
}
};

"Entity you are looking for was not found" at QBSubscriptions - Quickblox (Android)

I am using Quickblox SDK Ver 2.2.5 and I am trying to unsubscribe from Quickblox Push Notification's Subscriptions.
Previously before it was working fine & now instantly from past few weeks it stopped working.
Here following is my code:-
QBMessages.getSubscriptions(new QBEntityCallbackImpl<ArrayList<QBSubscription>>() {
#Override
public void onSuccess(
ArrayList<QBSubscription> subscriptions,
Bundle args) {
String deviceId = ((TelephonyManager) c
.getSystemService(Context.TELEPHONY_SERVICE))
.getDeviceId();
for (QBSubscription subscription : subscriptions) {
if (subscription.getDevice().getId()
.equals(deviceId)) {
QBMessages.deleteSubscription(
subscription.getId(),
new QBEntityCallbackImpl<Void>() {
#Override
public void onSuccess() {
Log.e("LOGOUT",
"GCM subscription removed from QB - successfully");
getEverythingDone();
}
#Override
public void onError(
List<String> errors) {
Log.e("LOGOUT",
"Error:"
+ errors);
}
});
break;
}
}
/** Added By Harpreet **/
unregisterForC2DM(c);
preferences.setdeviceToken("");
}
#Override
public void onError(List<String> errors) {
getEverythingDone();
Log.e("Subscriptions Errors", "Error:" + errors);
}
});
Error which I receive is:-
E/Subscriptions Errors(28923): Error:[Entity you are looking for was not found.]
I am not able to figure it out, as internet is already working and I am also logged-in to the chat because the process to final logout is in method getEverythingDone() which is used in my above described code.
Any idea, where I am wrong or is it again Quickblox guys (Have they messed up with their Api's again)?

Categories

Resources