Reward User
1. Fully Managed by MyChips
MCOfferwallSdk.instance.checkReward(
adUnitId: "YOUR_AD_UNIT_ID",
onReward: (reward) {
//do something with the reward, here we just print it out
//Be cautious: reward.virtualCurrencyReward returns a Double value.
print("Reward: ${reward.virtualCurrencyReward}");
},
onError: (e, st) {
//do something on error, here we just print it out
print("Error: $e");
print("Stacktrace: $st");
});void main() {
runApp(const MainApp());
}
class MainApp extends StatefulWidget {
const MainApp({super.key});
@override
State<MainApp> createState() => _MainAppState();
}
class _MainAppState extends State<MainApp> {
late final AppLifecycleListener _appLifecycleListener;
@override
void initState() {
super.initState();
initialize();
}
@override
void dispose() {
_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 id
await MCOfferwallSdk.instance.init("YOUR_API_KEY");
await MCOfferwallSdk.instance.setUserId("YOUR_USER_ID");
//check for reward when the app is initialized
checkReward();
//check for reward when the app is resumed
_appLifecycleListener = AppLifecycleListener(
onResume: () {
checkReward();
},
);
}
@override
Widget build(BuildContext context) {
return ...//your app body
}
}
2. Server-to-Server (S2S) Postbacks
Last updated