The first step in integrating with your app is to install the Tapjoy Flutter Plugin.
flutter pub add tapjoy_offerwall
You can then import Tapjoy into your application to use the plugin:
import 'package:tapjoy_offerwall/tapjoy_offerwall.dart';
The connect call is how we initialise the Tapjoy SDK. You should do this as soon as possible after your app launches
final Map<String, dynamic> optionFlags = {};
Tapjoy.connect(
sdkKey:
'SDK_KEY',
options: optionFlags,
onConnectSuccess: () async {
},
onConnectFailure: (int code, String? error) async {
},
onConnectWarning: (int code, String? warning) async {
});
Once you have finished configuing Tapjoy you can build and run your application.
Congratulations! You now have Tapjoy working in your application.
You can tell Tapjoy how many levels there are in your game. You can set this value before or after calling connect.
Tapjoy.setMaxLevel(10);
You can identify users as part of a segment by calling setUserSegment
. This can be set before or after calling connect.
Tapjoy.setUserSegment(TJSegment.nonPayer);
Tapjoy.setUserSegment(TJSegment.payer);
Tapjoy.setUserSegment(TJSegment.vip);
Tapjoy.setUserSegment(TJSegment.unknown);
If your application is designed to use App Tracking Transparency, to display the dialog to request permission for accessing the IDFA, update your Info.plist by including the NSUserTrackingUsageDescription key along with a custom message to describe this permission to use IDFA in your application.
Next install the app_tracking_transparency
package:
flutter pub add app_tracking_transparency
Import the library, and then show the permission dialog:
import 'package:app_tracking_transparency/app_tracking_transparency.dart';
...
final status = await AppTrackingTransparency.requestTrackingAuthorization();