在应用内购买:具有相同帐户的两台设备没有获得相同的购买商品
In App Purchase : Two devices with same account not getting same purchased items
我在尝试什么?
在配置了 X 电子邮件地址的 android 设备中购买商品。当我签入配置了相同电子邮件地址的另一台设备时。但在第一台设备上购买的商品在另一台设备上不可用。
我试过什么?
我试过使用:
inappBillingService.getPurchases(InAppBuyActivity.INAPPVERSION,
getPackageName(), "inapp", null);
也尝试使用 :
IabHelper.QueryInventoryFinishedListener mGotInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// handle error here
}
else {
// Not getting same purchased on both devices
}
}
};
我正在生成与 Playstore 版本具有相同版本名称和版本代码的签名 apk。
应用内结算版本 3 API 让您可以更轻松地将应用内结算集成到您的 applications.The 功能中,此版本包括改进的同步购买流程,API让您轻松跟踪消耗品的所有权,以及应用内购买数据的本地缓存。
1.检查你的代码,如果你使用消耗品或不
如果您使用消耗品,用户可以多次购买产品,google只存储一次购买详细信息并再次收到空白响应,因此请从您的应用中删除与消耗品相关的代码。
2。使用以下代码检查用户是否已购买商品
private IInAppBillingService mService = null;
//onCreare
try {
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
// bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mServiceConn, Context.BIND_AUTO_CREATE);
} catch (Exception e) {
e.printStackTrace();
}
// Method
ServiceConnection mServiceConn = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
Log.d("TEST", "mService ready to go!");
checkownedItems();
}
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
};
private void checkownedItems() {
try {
Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
if (ownedItems.getInt("RESPONSE_CODE") == 0) {
ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
if (purchaseDataList.size() > 0) {
// Item already Purchased....
// Manage your in-app view
}else{
// Item not purchased
}
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
在购买商品之前使用以上逻辑,如果商品未购买,则调用应用内 getPurchases() 否则隐藏或管理应用内视图。
我已经使用两台设备测试了该应用程序。反映购买需要一些时间。
如果我删除应用程序并重新安装它,那么新购买的项目就会出现。但是,如果我购买一件商品并同时在第二台设备上查看它,它不会在那里反映出来。
当用户尝试购买时,应用会显示已在第二台设备上购买的商品。但是,它在 inappBillingService.getPurchases
和 IabHelper.QueryInventory
中不可用。
我在尝试什么?
在配置了 X 电子邮件地址的 android 设备中购买商品。当我签入配置了相同电子邮件地址的另一台设备时。但在第一台设备上购买的商品在另一台设备上不可用。
我试过什么?
我试过使用:
inappBillingService.getPurchases(InAppBuyActivity.INAPPVERSION,
getPackageName(), "inapp", null);
也尝试使用 :
IabHelper.QueryInventoryFinishedListener mGotInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// handle error here
}
else {
// Not getting same purchased on both devices
}
}
};
我正在生成与 Playstore 版本具有相同版本名称和版本代码的签名 apk。
应用内结算版本 3 API 让您可以更轻松地将应用内结算集成到您的 applications.The 功能中,此版本包括改进的同步购买流程,API让您轻松跟踪消耗品的所有权,以及应用内购买数据的本地缓存。
1.检查你的代码,如果你使用消耗品或不
如果您使用消耗品,用户可以多次购买产品,google只存储一次购买详细信息并再次收到空白响应,因此请从您的应用中删除与消耗品相关的代码。
2。使用以下代码检查用户是否已购买商品
private IInAppBillingService mService = null;
//onCreare
try {
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
// bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mServiceConn, Context.BIND_AUTO_CREATE);
} catch (Exception e) {
e.printStackTrace();
}
// Method
ServiceConnection mServiceConn = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
Log.d("TEST", "mService ready to go!");
checkownedItems();
}
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
};
private void checkownedItems() {
try {
Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
if (ownedItems.getInt("RESPONSE_CODE") == 0) {
ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
if (purchaseDataList.size() > 0) {
// Item already Purchased....
// Manage your in-app view
}else{
// Item not purchased
}
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
在购买商品之前使用以上逻辑,如果商品未购买,则调用应用内 getPurchases() 否则隐藏或管理应用内视图。
我已经使用两台设备测试了该应用程序。反映购买需要一些时间。
如果我删除应用程序并重新安装它,那么新购买的项目就会出现。但是,如果我购买一件商品并同时在第二台设备上查看它,它不会在那里反映出来。
当用户尝试购买时,应用会显示已在第二台设备上购买的商品。但是,它在 inappBillingService.getPurchases
和 IabHelper.QueryInventory
中不可用。