I am new to in app subscription. I have looked at Google's official documentation but that wasn't helpful. In my app I want to integrate monthly in app subscription. There are no proper tutorials for subscription on YouTube either, there are only for one time in app products. All I know is that I need a product Id and license key for in app purchases and I have them both with me. Can anyone help me with subscription? Here is my code
public class MainActivity extends Activity implements BillingProcessor.IBillingHandler{
BillingProcessor bp;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
bp = new BillingProcessor(this, Constants.base64EncodedPublicKey, this);
bp.purchase(MainSellerActivity.this,"subscription_product_id");
}
#Override
public void onProductPurchased(String productId, TransactionDetails details) {
Toast.makeText(this, "Subscribed Successfully", Toast.LENGTH_SHORT).show();
}
#Override
public void onPurchaseHistoryRestored() {
}
#Override
public void onBillingError(int errorCode, Throwable error) {
}
#Override
public void onBillingInitialized() {
}
The provided code above is a little bit modified, but this is basically where I am stuck at. Everything is working fine with when I use android.test.purchased in place of product Id, but I am getting an error when I use an actual product Id. Please help. If possible please provide a complete code for subscription.
Try this library.it is easy to integrate
android-inapp-billing-v3
Related
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: ");
}
});
}
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
I've spent the better part of 2 days trying to understand and follow the "Getting Started" section in the Android SDK doc (I'm a noob, so please go slow). I've also been picking through Quickblox API documentation, Stack overflow Quickblox Q&A's, and the Quickblox sample code.
Could someone please explain how I can actually establish a very simple and basic session with the Quickblox backend?
In trying to do this myself, here's what's I've run into/discovered:
Under the section "Getting Started" (in http://quickblox.com/developers/Android) the following steps are outlined:
Initialize framework with application credentials
Create session
Login with existing user or register new one
Perform actions with QuickBlox communication services and any data entities (users, locations, files, custom objects, pushes etc.)
For #1 above, it gives the following code:
QBSettings.getInstance().fastConfigInit("961", "PBZxXW3WgGZtFZv", "vvHjRbVFF6mmeyJ");
I put the above in the OnCreate method of my activity.
Then, for #2, it says "To create an application session use this code:"
QBAuth.createSession(new QBEntityCallbackImpl<QBSession>() {
#Override
public void onSuccess(QBSession session, Bundle params) {
// success
}
#Override
public void onError(List<String> errors) {
// errors
}
});
I also add that to my OnCreate.
For #3, I continue to use the suggested code. Is this case, I am creating 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
}
});
Here's my full OnCreate code:
public class ChatCategoryActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat_category);
Toast.makeText(getApplicationContext(), "Toast Test!",
Toast.LENGTH_LONG).show();
//Initialize quickblox framework
QBSettings.getInstance().fastConfigInit("29430", "XNKu54nymZXFq3c", "3vy372mwtYwfJU7");
//create a quickblox application session
QBAuth.createSession(new QBEntityCallbackImpl<QBSession>() {
#Override
public void onSuccess(QBSession session, Bundle params) {
// success
Toast.makeText(getApplicationContext(), "App session created!",
Toast.LENGTH_LONG).show();
}
#Override
public void onError(List<String> errors) {
// errors
Toast.makeText(getApplicationContext(), "Failed to create app session!",
Toast.LENGTH_LONG).show();
}
});
// Register new user
final QBUser user = new QBUser("bob1", "bobobob1");
QBUsers.signUp(user, new QBEntityCallbackImpl<QBUser>() {
#Override
public void onSuccess(QBUser user, Bundle args) {
// success
Toast.makeText(getApplicationContext(), "User signed up!",
Toast.LENGTH_LONG).show();
}
#Override
public void onError(List<String> errors) {
// error
Toast.makeText(getApplicationContext(), "User sign-up failed!",
Toast.LENGTH_LONG).show();
}
});
}
}
So, when I run it, according to the toast that fires, the app session fails to be created. Additionally, the URL that the app posts is this:
https://api.quickblox.com/session.json?application_id=29430&auth_key=XNKu54nymZXFq3c&nonce=166079749×tamp=1444750770&signature=a412ecb12db54842f6816968a734b4fc2626509d
And the response is:
{"errors":["Token is required"]}
The only place a "token" is mentioned in the Android SDK doc is here:
It's also possible to initialise the SDK with an existent QuickBlox
token. It can be interesting in cases when you build a big system and
you have the server side which generates QuickBlox tokens for
example...
The implication is that the token is not necessary. But clearly it is.
Could someone please help me with what what I am missing? I'd be very grateful for the code I need, including how to generate the token (including the SHA signature) and use it to initialise the framework, create a session, create/login a user, etc....
Many thanks!
First check: internet connection, do you have the internet permission in your manifest?
<uses-permission android:name="android.permission.INTERNET"/>
Your code to create session and user looks fine but you can only sign up once the session is created !
Using your code it would looks like that :
public class ChatCategoryActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Initialize quickblox framework
QBSettings.getInstance().fastConfigInit("29430", "XNKu54nymZXFq3c", "3vy372mwtYwfJU7");
//create a quickblox application session
QBAuth.createSession(new QBEntityCallbackImpl<QBSession>() {
#Override
public void onSuccess(QBSession session, Bundle params) {
// success
Toast.makeText(getApplicationContext(), "App session created!",
Toast.LENGTH_LONG).show();
// Register new user
final QBUser user = new QBUser("bob1", "bobobob1");
QBUsers.signUp(user, new QBEntityCallbackImpl<QBUser>() {
#Override
public void onSuccess(QBUser user, Bundle args) {
// success
Toast.makeText(getApplicationContext(), "User signed up!",
Toast.LENGTH_LONG).show();
}
#Override
public void onError(List<String> errors) {
// error
Toast.makeText(getApplicationContext(), "User sign-up failed!",
Toast.LENGTH_LONG).show();
}
});
}
#Override
public void onError(List<String> errors) {
// errors
Toast.makeText(getApplicationContext(), "Failed to create app session!",
Toast.LENGTH_LONG).show();
}
});
}
}
If the credentials are OK, a new user should be created. (for security reasons don't forget to reset the credentials and update your code.)
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 had integrated GA in My app but still not able to get any data on GA dashboard.can anyone explain how to do it. dont add any link i had already checked all the sites regarding this.
public void onCreate(Bundle savedInstanceState)
{
tracker=GoogleAnalyticsTracker.getInstance();
tracker.startNewSession("id",this);
tracker.trackPageView("page");
boolean isTracker = tracker.dispatch();
Log.v(TAG, "isTracker "+isTracker);
}
#Override
protected void onDestroy()
{
super.onDestroy();
tracker.stopSession();
Log.v("newslistView","onDestory()");
}
Thank You.