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
Related
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.
I implemented the snapchat login in my Android app by referring to the snapchat login kit sdk guide.
I refer to the below code that uses a custom button.
// Get the login API
SnapLogin snapLogin = SnapLoginProvider.get(getContext());
View yourButtonView = findViewById(...);
yourButtonView.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// Start token grant
snapLogin.startTokenGrant(new LoginResultCallback() {
#Override
public void onStart() {
// Here you could update the UI to show login start
}
#Override
public void onSuccess(#NonNull String accessToken) {
// Here you could update the UI to show login success
}
#Override
public void onFailure(#NonNull LoginException exception) {
// Here you could update the UI to show login failure
}
});
}
});
Call startTokenGrant api to complete authentication in snapchat.
After authentication, callback is called when returning to my app.
Step 1 goes well.
But intermittently, the callback is not called.
I thought this was an error in the sdk, but I saw that it works normally in other apps.
Has anyone had an experience where the callback never gets called?
If yes, please help how to solve it.
(I'm developing using dev clientId right now, will this have any effect?)
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.
I'm trying to integrate Pinterest into an android application and I would like to retrieve all the pins for a specific user (obviously after the user has logged in). Is this possible to be achieved by utilising the api released by Pinterest? Many thanks.
Yes, this is possible, check Pinterest sample app on GitHub:
link
sample code:
private void fetchPins() {
adapter.setPinList(null);
adapter.notifyDataSetChanged();
PDKClient.getInstance().getMyPins(PIN_FIELDS, new PDKCallback() {
#Override
public void onSuccess(PDKResponse response) {
List<PDKPin> list=new Arraylist<>;
//getting pin list
list=response.getPinList();
}
#Override
public void onFailure(PDKException exception) {
_loading = false;
Log.e(getClass().getName(), exception.getDetailMessage());
}
}
);
}
Happy coding!
I'm trying to retrieve a list of all friends, but it always returns a zero size list... No exception nor fail...
I'm using following permissions:
Permission[] permissions = new Permission[] {
Permission.BASIC_INFO,
Permission.READ_FRIENDLISTS
};
and I'm using following code:
private static OnFriendsListener mOnFriendsListener = new OnFriendsListener()
{
#Override
public void onComplete(List<Profile> friends)
{
L.d(FacebookHelper.class, "OnFriendsListener::onComplete");
BusProvider.getInstance().post(new FacebookEvent(Type.Friends, friends));
}
#Override
public void onException(Throwable throwable)
{
L.d(FacebookHelper.class, "OnFriendsListener::onException");
L.e(FacebookHelper.class, new Exception(throwable));
}
#Override
public void onThinking()
{
}
#Override
public void onFail(String reason)
{
L.d(FacebookHelper.class, "OnFriendsListener::onFail");
}
};
public static void getFriends(SimpleFacebook simpleFacebook)
{
PictureAttributes pictureAttributes = Attributes.createPictureAttributes();
pictureAttributes.setType(PictureType.SMALL);
Properties properties = new Properties.Builder()
.add(Properties.ID)
.add(Properties.FIRST_NAME)
.add(Properties.LAST_NAME)
.add(Properties.PICTURE, pictureAttributes)
.add(Properties.BIRTHDAY).build();
simpleFacebook.getFriends(properties, mOnFriendsListener);
}
Can anybody help me out with this problem?
Are you using the Facebook SDK for Android v3.14? If so, make sure to request the "user_friends" permission which lets the app read friends who also logged into the app with Facebook.
Note: v3.14 uses Graph API 2.0 by default. In that version of the API, GET /me/friends returns friends who logged into the app with Facebook.
If you're building a feature to tag friends in a post, take a look at the Taggable Friends API:
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/taggable_friends
More info on the 2.0 changes is here:
https://developers.facebook.com/docs/apps/changelog#v2_0_login