Use this method only if you have selected Self-Managed Currency. If you already support S2S postback please skip this snippet.
To check for a reward use the checkReward function. It requires your adUnitId, a reward callback (which will be called if the checks shows that there is a reward), and an on error callback.
MCOfferwallSdk.instance.checkReward( adUnitId:"YOUR_AD_UNIT_ID", onReward: (reward) {//do something with the reward, here we just print it outprint("Reward: ${reward.virtualCurrencyReward}"); }, onError: (e, st) {//do something on error, here we just print it outprint("Error: $e");print("Stacktrace: $st"); });
If there is no reward and no error, nothing will happen
You should check for the reward whenever the app is started or resumed. Example integration:
voidmain() {runApp(constMainApp());}classMainAppextendsStatefulWidget {constMainApp({super.key});@overrideState<MainApp> createState() =>_MainAppState();}class_MainAppStateextendsState<MainApp> {latefinalAppLifecycleListener _appLifecycleListener;@overridevoidinitState() { super.initState();initialize(); }@overridevoiddispose() { _appLifecycleListener.dispose(); super.dispose(); }Future<void> checkReward() async {MCOfferwallSdk.instance.checkReward( adUnitId:"YOUR_AD_UNIT_ID", onReward: (reward) {log("Reward: ${reward.virtualCurrencyReward}"); }, onError: (e, st) {log("Error: $e StackTrace: $st"); }, ); }Future<void> initialize() async {//initialize the sdk and set the user idawaitMCOfferwallSdk.instance.init("YOUR_API_KEY");awaitMCOfferwallSdk.instance.setUserId("YOUR_USER_ID");//check for reward when the app is initializedcheckReward();//check for reward when the app is resumed _appLifecycleListener =AppLifecycleListener( onResume: () {checkReward(); }, ); }@overrideWidgetbuild(BuildContext context) {return ...//your app body }}
2. Server-to-Server (S2S) Postbacks
If you prefer server-to-server communication, MyChips can send a postback to your server with bonus information. The configuration for postbacks is available in your publisher dashboard. This method is useful for validating and securely rewarding users without client-side manipulation.