Register a callback that will be made anytime there is a change to purchases made on the device. This will be triggered when a purchase process is started and may have different states based on the particular store platform.

Note that the name of this method varies slightly by language.

NamiPurchaseManager.registerPurchasesChangedHandler { (purchases, purchaseState, error) in
    // process purchases data
}
[NamiPurchaseManager registerPurchasesChangedHandler:^((NSArray<NamiPurchase *> * _Nonnull) purchases, (NamiPurchaseState) purchaseState, (NSError * _Nullable) error) {
        // React to puchase changes
    }];
NamiPurchaseManager.registerPurchasesChangedListener { purchases, purchaseState, error ->
  // process purchases and state
}
NamiPurchaseManager.registerPurchasesChangedListener((namiPurchases, namiPurchaseState, error) -> {
    // process purchases and state
    return Unit.INSTANCE;
});
useEffect(() => {
  eventEmitter.addListener('PurchasesChanged', onPurchasesChanged);
}
          
const onPurchasesChanged = (event) => {  
  // process based on event.purchaseState
}
NamiPurchaseManager.purchaseChangeEvents().listen((purchaseChangeEventData) {
    // process purchases and state
});


class PurchaseChangeEventData {
  final List<NamiPurchase> activePurchases;
  final NamiPurchaseState purchaseState;
  final String error;
}
NamiPurchaseManager.RegisterPurchasesChangedHandler([NullAllowed] Action<NSArray<NamiPurchase>, NamiPurchaseState, NSError> changeHandler);

Returns

  • purchases - a list of the current purchases
  • purchaseState - the state of the purchase, see NamiPurchaseState for all options
  • error - information about an error if one occurred, generated by the store platform making the purchase