flutter_tapjoy 1.0.0 copy "flutter_tapjoy: ^1.0.0" to clipboard
flutter_tapjoy: ^1.0.0 copied to clipboard

unlistedoutdated

A plugin for Tapjoy for both Android & iOS

Tapjoy Plugin for Flutter #

Note: There are seperate implementations for Android & iOS. For iOS, replace your AppDelegate.swift with the example repo's AppDelegate.swift file & add pod TapjoySDK at the end of your Podfile.

Getting started: #

1. Initialise Tapjoy #

Call initTapjoy() during app initialization Replace api_key with your Tapjoy key.

 Future<void> initTapjoy() async {
    if (Platform.isAndroid) {
      Tapjoy.setDebugEnabled(true);
      Tapjoy.setUserConsent('1');
      Tapjoy.connect(
        'api_key',
        tapjoyConnectSuccess,
        tapjoyConnectFailure,
      );
    } else if (Platform.isIOS) {
      TapjoyiOS.setDebugEnabled(true);
      TapjoyiOS.setUserConsent('1');
      TapjoyiOS.connect(
          'api_key');
    }
  }

2. Initialise callback listeners #

//For Android
void tapjoyConnectSuccess() {
   Tapjoy.setActivity();
   print('Tapjoy SDK connected');
 }

 void tapjoyConnectFailure() {
   print('Tapjoy SDK connection failure');
 }

//For iOS
 listener(TapjoySwiftListener event) {
   switch (event) {
     case TapjoySwiftListener.contentIsReady:
       print('TAPJOY: content is ready');
       TapjoyiOS.showContent();
       break;
     case TapjoySwiftListener.requestDidFail:
       print('TAPJOY: request failed');
       break;
     case TapjoySwiftListener.requestDidSucceed:
       print('TAPJOY: request successful');
       break;
     case TapjoySwiftListener.didRequestReward:
       print('TAPJOY: reward requested');
       break;
     case TapjoySwiftListener.contentDidAppear:
       print('TAPJOY: content did appear');
       break;
     case TapjoySwiftListener.contentDidDisappear:
       print('TAPJOY: content did disappear');
       break;
   }
 }

3. Call TJPlacement #

Replace placement_name with your Tapjoy placement.

     if (Platform.isAndroid) {
                TJPlacement tjPlacement = await Tapjoy.getPlacement('placement_name',
                    onRequestSuccess: (placement) => placement.showContent(),
                    onRequestFailure: (placement, error) => print(
                        error.errorCode.toString() +
                            ' - ' +
                            error.errorMessage));
                tjPlacement.requestContent();
              } else if (Platform.isIOS) {
                TapjoyiOS.getPlacement('placement_name');
                TapjoyiOS.requestContent(listener);
              }

For the complete implementation, please refer to the example repo.

8
likes
0
pub points
69%
popularity

Publisher

verified publisheranavrinapps.com

A plugin for Tapjoy for both Android & iOS

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_tapjoy