我知道之前已被问到,但我发现的所有问题都是陈旧的。我想,也许事情发生了变化。
我想提供试用期,用户可以使用所有功能。我不喜欢谷歌在应用程序购买系统中这样做的方式..它使用户支付订阅费用,并提供在试用期结束前取消它的选项。
我想要的是在不让用户提前付款的情况下提供试用版。这可能是使用谷歌的API吗?还是我必须使用我自己的服务器?
答案 0 :(得分:0)
我已经开发了一个Android trial library,您只需将其放入您的项目中,它将为您处理所有服务器端管理(包括脱机宽限期),因此您不需要自己的服务器
要使用它,只需
将库添加到主模块的build.gradle
dependencies {
compile 'io.trialy.library:trialy:1.0.2'
}
在主要活动的onCreate()
方法
@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);
}
添加回调处理程序:
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));
}
};
要开始试用,请致电mTrialy.startTrial("YOUR_TRIAL_SKU", mTrialyCallback);
您的应用密钥和试用SKU可以在Trialy developer dashboard。