Anonymous
Anonymous

Reputation: 4910

Android - How to implement free trial period without making the user pay in advance

I know it has been asked before but all questions I found are old. I figured that maybe something has changed since.

I want to offer a trial period where the user can use all the features. I dont like the way Google in app purchases system does this..It makes the user pay for the subscription and gives the option to cancel it before the trial is over.

What I want is to offer the trial without making the user pay for it in advance. Is that possbile using Google's APIs or do I have to use my own server for this ?

Upvotes: 1

Views: 1253

Answers (1)

Nick
Nick

Reputation: 3494

I've developed an Android trial library which you can simply drop into your project and it will take care of all the server-side management for you (including offline grace periods) so you don't need your own server.

To use it, simply

Add the library to your main module's build.gradle

dependencies {
  compile 'io.trialy.library:trialy:1.0.2'
}

Initialize the library in your main activity's onCreate() method

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Initialize the library and check the current trial status on every launch
    Trialy mTrialy = new Trialy(mContext, "YOUR_TRIALY_APP_KEY");
    mTrialy.checkTrial(TRIALY_SKU, mTrialyCallback);
}

Add a callback handler:

private TrialyCallback mTrialyCallback = new TrialyCallback() {
    @Override
    public void onResult(int status, long timeRemaining, String sku) {
        switch (status){
            case STATUS_TRIAL_JUST_STARTED:
                //The trial has just started - enable the premium features for the user
                 break;
            case STATUS_TRIAL_RUNNING:
                //The trial is currently running - enable the premium features for the user
                break;
            case STATUS_TRIAL_JUST_ENDED:
                //The trial has just ended - block access to the premium features
                break;
            case STATUS_TRIAL_NOT_YET_STARTED:
                //The user hasn't requested a trial yet - no need to do anything
                break;
            case STATUS_TRIAL_OVER:
                //The trial is over
                break;
        }
        Log.i("TRIALY", "Trialy response: " + Trialy.getStatusMessage(status));
    }

};

To start a trial, call mTrialy.startTrial("YOUR_TRIAL_SKU", mTrialyCallback); Your app key and trial SKU can be found in your Trialy developer dashboard.

Upvotes: 0

Related Questions