Skip to main content

Ready to market your stellar app?

Samsung Developer Program is your gateway to app monetization success.

Learn More

Samsung Developer Program

Unsubscribe to Plugin Events

To prevent memory leaks or to free memory, unsubscribe to OpenIAB plugin events via the OpenIABEventManager class, which unregisters the listeners that were previously set in Awake().

In City Flyer, unsubscribing is implemented in the onDestroy() class. 

In Unity, onDestroy() is invoked when the class will be destroyed.

// Remove listeners when the application exits

private void onDestroy()
        // Remove listeners from the event manager to avoid nasty leaks
        OpenIABEventManager.billingSupportedEvent -= onBillingSupported;
        OpenIABEventManager.billingNotSupportedEvent -= OnBillingNotSupported;
        OpenIABEventManager.queryInventorySucceededEvent -= OnQueryInventorySucceeded;
        OpenIABEventManager.queryInventoryFailedEvent -= OnQueryInventoryFailed;
        OpenIABEventManager.purchaseSucceededEvent -= OnPurchaseSucceeded;
        OpenIABEventManager.purchaseFailedEvent -= OnPurchaseFailed;
        OpenIABEventManager.consumePurchaseSucceededEvent -= OnConsumePurchaseSucceeded;
        OpenIABEventManager.consumePurchaseFailedEvent -= OnConsumePurchaseFailed;
        OpenIABEventManager.transactionRestoredEvent -= OnTransactionRestored;
        OpenIABEventManager.restoreSucceededEvent -= OnRestoreSucceeded;
        OpenIABEventManager.restoreFailedEvent -= OnRestoreFailed;

  • Was this article helpful?