visual_reward 1.1.5
visual_reward: ^1.1.5 copied to clipboard
Tenqube Visual Reward SDK for Flutter. A reward-ad webview SDK built on flutter_inappwebview for Android and iOS.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:visual_reward/visual_reward.dart';
void main() {
// WebView 디버깅은 initialize 전에 설정합니다. (디버그 빌드에서만 켜는 것을 권장)
VisualReward.setDebugEnabled(true);
// SDK 초기화 — 앱 시작 시 한 번만 호출합니다.
VisualReward.initialize(
appKey: 'tq_live_xxx',
timeout: const Duration(seconds: 5),
onSuccess: () => debugPrint('VisualReward initialized'),
onFailure: (error) => debugPrint('VisualReward init failed: $error'),
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Visual Reward Example',
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
void _openReward(BuildContext context) {
// open 전에 사용자 식별자를 반드시 설정합니다.
VisualReward.setUserId('user-123');
VisualReward.open(
context: context,
serviceName: 'reward_home',
locale: 'ko',
onClose: () => debugPrint('reward webview closed'),
onError: (error) {
if (error is VisualRewardUserIdNotSetError) {
debugPrint('setUserId 를 먼저 호출하세요');
} else if (error is VisualRewardNetworkError) {
debugPrint('네트워크 오류');
} else {
debugPrint('open 실패: $error');
}
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Visual Reward Example')),
body: Center(
child: ElevatedButton(
onPressed: () => _openReward(context),
child: const Text('리워드 열기'),
),
),
);
}
}