You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-16 14:00:40 +00:00
Add signals and a check function for Android service connectivity.
- Add a iap_connect and iap_disconnect events for android platform. - Add isConnected() function returning true if its connected to android service, false otherwise
This commit is contained in:
@@ -67,7 +67,7 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
|
|||||||
|
|
||||||
public GodotPaymentV3(Activity p_activity) {
|
public GodotPaymentV3(Activity p_activity) {
|
||||||
|
|
||||||
registerClass("GodotPayments", new String[]{"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume", "querySkuDetails"});
|
registerClass("GodotPayments", new String[]{"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume", "querySkuDetails", "isConnected"});
|
||||||
activity = (Godot) p_activity;
|
activity = (Godot) p_activity;
|
||||||
mPaymentManager = activity.getPaymentsManager();
|
mPaymentManager = activity.getPaymentsManager();
|
||||||
mPaymentManager.setBaseSingleton(this);
|
mPaymentManager.setBaseSingleton(this);
|
||||||
@@ -164,6 +164,19 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
|
|||||||
GodotLib.calldeferred(purchaseCallbackId, "has_purchased", new Object[]{receipt, signature, sku});
|
GodotLib.calldeferred(purchaseCallbackId, "has_purchased", new Object[]{receipt, signature, sku});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void callbackDisconnected() {
|
||||||
|
GodotLib.calldeferred(purchaseCallbackId, "iap_disconnected", new Object[]{});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void callbackConnected() {
|
||||||
|
GodotLib.calldeferred(purchaseCallbackId, "iap_connected", new Object[]{});
|
||||||
|
}
|
||||||
|
|
||||||
|
// true if connected, false otherwise
|
||||||
|
public boolean isConnected() {
|
||||||
|
return mPaymentManager.isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
// consume item automatically after purchase. default is true.
|
// consume item automatically after purchase. default is true.
|
||||||
public void setAutoConsume(boolean autoConsume) {
|
public void setAutoConsume(boolean autoConsume) {
|
||||||
mPaymentManager.setAutoConsume(autoConsume);
|
mPaymentManager.setAutoConsume(autoConsume);
|
||||||
|
|||||||
@@ -92,11 +92,21 @@ public class PaymentsManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
mService = null;
|
mService = null;
|
||||||
|
|
||||||
|
// At this stage, godotPaymentV3 might not have been initialized yet.
|
||||||
|
if (godotPaymentV3 != null) {
|
||||||
|
godotPaymentV3.callbackDisconnected();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
mService = IInAppBillingService.Stub.asInterface(service);
|
mService = IInAppBillingService.Stub.asInterface(service);
|
||||||
|
|
||||||
|
// At this stage, godotPaymentV3 might not have been initialized yet.
|
||||||
|
if (godotPaymentV3 != null) {
|
||||||
|
godotPaymentV3.callbackConnected();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -123,6 +133,10 @@ public class PaymentsManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isConnected() {
|
||||||
|
return mService != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void consumeUnconsumedPurchases() {
|
public void consumeUnconsumedPurchases() {
|
||||||
new ReleaseAllConsumablesTask(mService, activity) {
|
new ReleaseAllConsumablesTask(mService, activity) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user