Code Monkey home page Code Monkey logo

flutter_advertising_plugins's Introduction

Flutter Plugins

This repo contains the source code for Flutter plugins developed for various ad-networks developed by Arnav Varyani.

Flutter plugins enable access to platform-specific APIs using a platform channel. For more information about plugins, and how to use them, see https://flutter.io/platform-plugins/.

Issues

Please check existing issues and file any new issues, bugs, or feature requests at (https://github.com/AnavrinApps/flutter_plugins/issues) .

flutter_advertising_plugins's People

Contributors

arnavvaryani avatar

Stargazers

 avatar Artem avatar  avatar Asjad avatar  avatar A avatar André Filipe avatar Landersson avatar Yash Chandra Verma avatar

flutter_advertising_plugins's Issues

compilation error for mopub_flutter: 1.2.2+1 on iOS

I get the following compilation errors (Flutter 2.5.0-5.2.pre)

    import MoPub
           ^
    /Users/eliabieri/.pub-cache/hosted/pub.dartlang.org/mopub_flutter-1.2.2+1/ios/Classes/MopubBannerAd.swift:9:8: error: no such module 'MoPub'
    import MoPub
           ^
    /Users/eliabieri/.pub-cache/hosted/pub.dartlang.org/mopub_flutter-1.2.2+1/ios/Classes/MopubBannerAd.swift:9:8: error: no such module 'MoPub'
    import MoPub
           ^
    /Users/eliabieri/.pub-cache/hosted/pub.dartlang.org/mopub_flutter-1.2.2+1/ios/Classes/MopubBannerAd.swift:9:8: error: no such module 'MoPub'
    import MoPub
           ^
    /Users/eliabieri/.pub-cache/hosted/pub.dartlang.org/mopub_flutter-1.2.2+1/ios/Classes/MopubBannerAd.swift:9:8: error: no such module 'MoPub'
    import MoPub
           ^
    /Users/eliabieri/.pub-cache/hosted/pub.dartlang.org/mopub_flutter-1.2.2+1/ios/Classes/MopubBannerAd.swift:9:8: error: no such module 'MoPub'

How it use

I try to use flutter_tapjoy, I copy example code from pub dev, first I try to run it on iOS simulator and I get
MissingPluginException(No implementation found for method connectTapJoy on channel flutter_tapjoy)

I found issue and it says update dependencies, I did it, recreated the flutter project, did flutter clear, flutter pub upgrade, flutter pub outdated and still got this error, I tried to run it on an android simulator and there I got an error
test/android/app/src/debug/AndroidManifest.xml:13:9-79 Error: Attribute activity#com.tapjoy.TJAdUnitActivity@theme value=(@android:style/Theme.Translucent.NoTitleBar.Fullscreen) from AndroidManifest.xml:13:9-79 is also present at [com.tapjoy:tapjoy-android-sdk:13.0.1] AndroidManifest.xml:27:13-71 value=(@android:style/Theme.NoTitleBar.Fullscreen). Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:14:9-18:86 to override.
so that's what I should do how to run it

flutter doctor logs:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 3.16.0-0.3.pre, on macOS 14.1 23B73 darwin-arm64, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.71.0)
[✓] Connected device (4 available)
[✓] Network resources
• No issues found!

thank you in advance for your help

I am getting error when I ad this plugin

, I tried Cache clean and everything. please help . Below is flutter doctor out put and error details:

Error :

android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java:19: error: package com.anavrinapps.adcolony_flutter.adcolony_flutter does not exist
flutterEngine.getPlugins().add(new com.anavrinapps.adcolony_flutter.adcolony_flutter.AdcolonyFlutterPlugin());
^
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Flutter Doctor Output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19043.1586], locale en-PK)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.1)
[√] VS Code (version 1.65.1)
[√] Connected device (4 available)
[√] HTTP Host Availability

! Doctor found issues in 1 category.

tapjoy --- ios

MissingPluginException(No implementation found for method requestContent on channel native)

real Interstial ads not showing while using mediation with facebook

Hi there, Thank you for this awesome package. But I am unable to show Interstials ads in my app by using plugin. Banner ad is successfully integrated with facebook and facebook ads are showing by using advanced bidding. But the interstial ads are not shown, I am pretty much sure that I have integrated this package correctly still I do not get adrequest too . Working fine for banner but not for interstials . Please fix it as soon as possible or let me know what should I do to fix this

trsurveys: Not building in iOS

When i try to compile the app for debug on iOS it fails to build

Semantic Issue (Xcode): Duplicate interface definition for class 'TrsurveysPlugin'
/Users/<>/<>/<>/build/ios/Debug-iphonesimulator/trsurveys/trsurveys.framework/Headers/trsurveys-Swift.h:620:0

Uncategorized (Xcode): Command SwiftEmitModule failed with a nonzero exit code


Banner ads never load successfully, Mopub Flutter

It keeps saying ad failed to load. Reward ads work perfectly though and I waited several days and tried loading banner ads for almost a week and they never worked. It seems that every bammer ad is a tapjoy call id I am not mistaken. Also, can you update the documentation in a way to know how to use mediation and adding adapters please, cuz there is nothing on the ineternet on how to use adapters in flutter. Thank you very much.

TJConnectionResult.disconnected in release mode

the plugin works in debug mode but in release mode it doesnt connect.
here is my code:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter_tapjoy/flutter_tapjoy.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:smilenow/Scoped_model/main.dart';

class TapjoyLayout extends StatefulWidget{
MainModel model;
TapjoyLayout(this.model);
@OverRide
State createState() {
// TODO: implement createState
return TapjoyLayoutState();
}
}

class TapjoyLayoutState extends State{
String connectionState = "";
TJPlacement myPlacement = TJPlacement(name: "offerwall");
bool ready=false;

TJSpendCurrencyHandler _currencyHandler() {
TJSpendCurrencyHandler handler = (currencyName, amount, error) {

  if(amount!=0&&amount!=null){
    Firestore.instance.collection("User").document(widget.model.userId).get().then((value){
      value.reference.updateData({
        "diamonds":value.data['diamonds']+amount
      });
      if(amount!=0){
        Firestore.instance.collection("history").add({
          "diamonds":amount,
          "email":widget.model.uemail,
          "type":"TapJoy Offerwall",
          "dt":DateTime.now()
        });
      }

      TapJoyPlugin.shared.spendCurrency(amount);

    });}
};
return handler;

}

TJConnectionResultHandler _connectionResultHandler() {
TJConnectionResultHandler handler = (result) {
print(result);
switch (result) {
case TJConnectionResult.connected:
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Connecting to TapJoy")));
myPlacement.requestContent();
print(connectionState);
break;
case TJConnectionResult.disconnected:
print(connectionState);
break;
}
};
return handler;
}

TJPlacementHandler _placementHandler() {
TJPlacementHandler handler = (contentState, name, error) {
switch (contentState) {
case TJContentState.contentReady:
setState(() {
ready=true;
});

      break;
    case TJContentState.contentDidAppear:
      print(contentState);
      break;
    case TJContentState.contentDidDisappear:
      setState(() {
        ready=false;
      });
      break;
    case TJContentState.contentRequestSuccess:
      ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Requesting Tapjoy")));
      break;
    case TJContentState.contentRequestFail:
      setState(() {
        ready=false;
      });
      ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Request Failed")));
      break;
    case TJContentState.userClickedAndroidOnly:

      setState(() {
        ready=false;
      });

      break;
  }
};
return handler;

}
@OverRide
void initState() {
// TODO: implement initState
super.initState();
TapJoyPlugin.shared.setConnectionResultHandler(_connectionResultHandler());
// connect to TapJoy, all fields are required.
TapJoyPlugin.shared.connect(
androidApiKey: "xyz",
iOSApiKey: "tap_joy_ios_api_key",
debug: false);
// set userID
TapJoyPlugin.shared.setUserID(userID: widget.model.userId);
// set contentState handler for each placement
myPlacement.setHandler(_placementHandler());

// add placements.
TapJoyPlugin.shared.addPlacement(myPlacement);

// set currency Handlers
TapJoyPlugin.shared.setGetCurrencyBalanceHandler(_currencyHandler());
TapJoyPlugin.shared.setAwardCurrencyHandler(_currencyHandler());
TapJoyPlugin.shared.setSpendCurrencyHandler(_currencyHandler());
TapJoyPlugin.shared.setEarnedCurrencyAlertHandler(_currencyHandler());

}

@OverRide
Widget build(BuildContext context) {
// TODO: implement build
return InkWell(
onTap: ()async{
bool v=await TapJoyPlugin.shared.isConnected();
print(v);
if(await TapJoyPlugin.shared.isConnected()==true){
TapJoyPlugin.shared.getCurrencyBalance();
if(ready==true){
myPlacement.showPlacement();
}else{
myPlacement.requestContent();
}
}else{
await TapJoyPlugin.shared.setConnectionResultHandler(_connectionResultHandler());
await TapJoyPlugin.shared.connect(
androidApiKey: "xyz",
iOSApiKey: "tap_joy_ios_api_key",
debug: false);
// set userID
TapJoyPlugin.shared.getCurrencyBalance();
if(ready==true){
myPlacement.showPlacement();
}else{
myPlacement.requestContent();
}
}

  },
  child: Card(
    elevation:10,

    child:Container(
      height: 100,
      width: MediaQuery.of(context).size.width/2-25,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(4)),
        //color: Colors.white,

      ),

      child: ClipRRect(
          borderRadius: BorderRadius.all(Radius.circular(8)),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Row(

                children: [
                  SizedBox(width: 10,),
                  Container(
                    height: 80,
                    width: 80,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(16)),
                      color: Color(0xffbff5400),
                    ),
                    child: Icon(Icons.stars_outlined,size: 48,color: Colors.white,),

                  ),
                  SizedBox(width: 10,),
                  Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text("Max Task",style: GoogleFonts.bebasNeue(
                          textStyle: TextStyle(
                            color: Colors.black,fontSize: 24,letterSpacing: 1,
                            fontWeight: FontWeight.normal,

                          )
                      ),),
                      Text("Complete Max Task",style: GoogleFonts.bebasNeue(
                          textStyle: TextStyle(
                            color: Colors.black,fontSize: 18,letterSpacing: 1,
                            fontWeight: FontWeight.normal,

                          )
                      ),),
                    ],
                  ),
                  Spacer(),
                  CircleAvatar(
                    backgroundColor: Colors.grey[300],
                    child: IconButton(onPressed: (){
                      TapJoyPlugin.shared.getCurrencyBalance();
                      if(ready==true){
                        myPlacement.showPlacement();
                      }else{
                        myPlacement.requestContent();
                      }
                    }, icon: Icon(Icons.arrow_forward_ios_sharp,color: Colors.grey[500],size: 28,)),
                  ),
                  SizedBox(width: 15,),
                ],
              ),



            ],
          )
      ),
    ),
  ),
);

}
}

Not able to use mopub_flutter: ^1.2.2+1 in ios

I tried using mopub_flutter: ^1.2.2+1 in MAC machine and I am getting the following error. Could you please help me resolving this issue

ios/Pods/mopub-ios-sdk/MoPubSDK/Internal/Utility/Categories/SKAdImpression+ConvenienceServerResponseInitializer.swift:12:11: error: cannot find type 'SKAdImpression' in scope
extension SKAdImpression {
^~~~~~~~~~~~~~
ios/Pods/mopub-ios-sdk/MoPubSDK/Internal/Common/SKAdNetworkData.swift:113:38: error: cannot find type 'SKAdImpression' in scope
@objc public var impressionData: SKAdImpression? {
^~~~~~~~~~~~~~
ios/Pods/mopub-ios-sdk/MoPubSDK/Internal/Common/SKAdNetworkData.swift:88:42: error: cannot find 'SKAdImpression' in scope
localImpressionDataStorage = SKAdImpression(serverResponse: impressionResponseDictionary) ?? nil
^~~~~~~~~~~~~~
ios/Pods/mopub-ios-sdk/MoPubSDK/Internal/Utility/Categories/SKAdImpression+ConvenienceServerResponseInitializer.swift:12:11: error: cannot find type 'SKAdImpression' in scope
extension SKAdImpression {
^~~~~~~~~~~~~~
ios/Pods/mopub-ios-sdk/MoPubSDK/Internal/Common/SKAdNetworkData.swift:113:38: error: cannot find type 'SKAdImpression' in scope
@objc public var impressionData: SKAdImpression? {
^~~~~~~~~~~~~~
ios/Pods/mopub-ios-sdk/MoPubSDK/Internal/Common/SKAdNetworkData.swift:88:42: error: cannot find 'SKAdImpression' in scope
localImpressionDataStorage = SKAdImpression(serverResponse: impressionResponseDictionary) ?? nil

No Ads show en AdColony

Hi. I am trying to implement the AdColony Plugin, but when displaying Banners or FullScreen they are not displayed. In the case of FullScreen it says "onRequestNotFilled".

Any idea?

Actually I use AdColony from Google AdMob mediation and they are displayed, so it is not a problem of the AdColony account.

flutter_tapjoy TJPrivacyPolicy support?

Hi,
Thank you for providing a good package.
It seems that flutter_tapjoy does not support TJPrivacyPolicy.
Do you have any plans to support TJPrivacyPolicy?

thx

here is new error.

offerwall webpage can't be open.

E/Tapjoy (16591): Error java.lang.IllegalStateException: Reply already submitted

ayeT-Studios SDK version

Can you please upgrade ayeT-Studios SDK version to latest? We can't use the plugin in the current version.

Received status code 403 from server: Forbidden while compiling plugin

 > Could not resolve com.adcolony:sdk:4.2.2.
     > Could not get resource 'https://s3.amazonaws.com/moat-sdk-builds/com/adcolony/sdk/4.2.2/sdk-4.2.2.pom'.
        > Could not GET 'https://s3.amazonaws.com/moat-sdk-builds/com/adcolony/sdk/4.2.2/sdk-4.2.2.pom'. Received status code 403 from server: Forbidden
  > Could not resolve com.adcolony:sdk:4.2.2.
     > Could not get resource 'https://tapjoy.bintray.com/maven/com/adcolony/sdk/4.2.2/sdk-4.2.2.pom'.
        > Could not GET 'https://tapjoy.bintray.com/maven/com/adcolony/sdk/4.2.2/sdk-4.2.2.pom'. Received status code 403 from server: Forbidden
  > Could not resolve com.adcolony:sdk:4.2.2.
     > Could not get resource 'https://adcolony.bintray.com/AdColony/com/adcolony/sdk/4.2.2/sdk-4.2.2.pom'.
        > Could not GET 'https://adcolony.bintray.com/AdColony/com/adcolony/sdk/4.2.2/sdk-4.2.2.pom'. Received status code 403 from server: Forbidden

Could not resolve com.tapjoy:tapjoy-android-sdk:12.6.1.
Required by:
project :app > project :mopub_flutter
> Could not resolve com.tapjoy:tapjoy-android-sdk:12.6.1.
> Could not get resource 'https://s3.amazonaws.com/moat-sdk-builds/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'.
> Could not GET 'https://s3.amazonaws.com/moat-sdk-builds/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'. Received status code 403 from server: Forbidden
> Could not resolve com.tapjoy:tapjoy-android-sdk:12.6.1.
> Could not get resource 'https://tapjoy.bintray.com/maven/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'.
> Could not GET 'https://tapjoy.bintray.com/maven/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'. Received status code 403 from server: Forbidden
> Could not resolve com.tapjoy:tapjoy-android-sdk:12.6.1.
> Could not get resource 'https://adcolony.bintray.com/AdColony/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'.
> Could not GET 'https://adcolony.bintray.com/AdColony/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'. Received status code 403 from server: Forbidden
Could not resolve com.tapjoy:tapjoy-android-sdk:12.6.1.
Required by:
project :app > project :mopub_flutter
> Could not resolve com.tapjoy:tapjoy-android-sdk:12.6.1.
> Could not get resource 'https://s3.amazonaws.com/moat-sdk-builds/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'.
> Could not GET 'https://s3.amazonaws.com/moat-sdk-builds/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'. Received status code 403 from server: Forbidden
> Could not resolve com.tapjoy:tapjoy-android-sdk:12.6.1.
> Could not get resource 'https://tapjoy.bintray.com/maven/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'.
> Could not GET 'https://tapjoy.bintray.com/maven/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'. Received status code 403 from server: Forbidden
> Could not resolve com.tapjoy:tapjoy-android-sdk:12.6.1.
> Could not get resource 'https://adcolony.bintray.com/AdColony/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'.
> Could not GET 'https://adcolony.bintray.com/AdColony/com/tapjoy/tapjoy-android-sdk/12.6.1/tapjoy-android-sdk-12.6.1.pom'. Received status code 403 from server: Forbidden

Set Placement Handler Not Called

Hi!

I'm pretty sure that the method Future<Null> _handleMethod(MethodCall call) never actually gets called by the native Swift code.

I found this out because I'm trying to implement the placement handler for my ad placement...

I can set the handler by calling this method here:
myPlacement.setHandler(_placementHandler());

And I've been debugging it and it definitely shows that the handler is a member variable of the TJPlacement placement class instance...

But then the handler function doesn't actually get called. In fact... the entire _handleMethod never gets called at all either.

I'm just using the very basic example listed here: https://pub.dev/packages/flutter_tapjoy/example

The only things I changed were my api keys.
androidApiKey: "tap_joy_android_api_key", iOSApiKey: "tap_joy_ios_api_key",

The ads ARE loading... and I DO see debug printouts like:
[TJLog level: 4] Content is ready for placement DemoPlacement

but then the code doesn't call the placement handler at all.

Let me know what other info I can provide to help debug this!

Maybe I'm just doing something wrong here...

Thanks so much!

It crashes with firebase.

Hello.

I only registered [flutter_tapjoy: ^2.1.0], it crashes with firebase.

It only crashes on iOS.
Android works normally.

crash...

MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)

Thank you.


[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-arm, locale ko-KR)
    • Flutter version 3.0.2 at /Users/jeonglockpark/Desktop/work/flutter_sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (2 weeks ago), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/jeonglockpark/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.68.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

on release

after completing offer, reward status shows nothing and second thing is their is no option to store reward amount into firestore database.

``import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:hiddentechgaming/components/rounded_button.dart';
import 'package:flutter_svg/svg.dart';
import 'dart:async';
import 'package:flutter_tapjoy/flutter_tapjoy.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../constants.dart';

void main() async {
runApp(TapJoy());
}

class TapJoy extends StatefulWidget {
@OverRide
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State {
int ccoins = 0;
int total = 0;
final firestoreInstance = Firestore.instance;
final databaseReference = Firestore.instance;

Future initTapjoy() async {
Tapjoy.instance.setDebugEnabled(isDebug: false);
Tapjoy.instance.setUserConsent(consent: 'consent');
Tapjoy.instance.connect(
apiToken:
'frkd7Rf2RXWtW_DAnxgp4wECHdJes13cZBYzpA1V4MeHpVAdeWHyBSWPNzbA');
Tapjoy.instance.setOnTapjoyConnectSuccessListener(tapjoySuccess);
Tapjoy.instance.setonPlacementRequestFailureListener(tapjoyError);
Tapjoy.instance.setonRewardRequestListener(tapjoyReward);
Tapjoy.instance.setonContentReadyListener(tapjoyisReady);
}

void tapjoySuccess() {
Tapjoy.instance.getPlacement(placementName: 'Appearn');
print('tapjoy success');
}

void tapjoyError(String error) {
print('Tapjoy Placement ERROR: $error');
}

void tapjoyReward(int quantity) async {
print('Tapjoy SDK $quantity');
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
total = (ccoins += quantity) * (prefs.getInt('counter') ?? 0);
prefs.setInt('counter', ccoins);
});
var firebaseUser = await FirebaseAuth.instance.currentUser();
firestoreInstance.collection("coins").document(firebaseUser.uid).setData({
"coins": ccoins,
}).then((_) {
print("success!");
});
}

void tapjoyisReady() {
Tapjoy.instance.showContent();
print('Tapjoy SDK Ready');
}

@OverRide
void initState() {
initTapjoy();
_subt();
_loadCounter();
super.initState();
}

_loadCounter() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
ccoins = _subt() + (prefs.getInt('counter'));
});
}

_subt() async {
var firebaseUser = await FirebaseAuth.instance.currentUser();
firestoreInstance
.collection("coins")
.document(firebaseUser.uid)
.get()
.then((value) {
print(value.data);
setState(() => ccoins = value.data['coins'].toInt());
});
}

@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: buildAppBar(),
body: Center(
child: Column(
children: [
RoundedButton(
text: "Content Available ?",
press: () async {
Tapjoy.instance.requestContent();
},
),
],
),
),
),
debugShowCheckedModeBanner: false);
}

AppBar buildAppBar() {
return AppBar(
title: Text("Tapjoy"),
backgroundColor: Colors.deepPurple,
elevation: 0,
leading: IconButton(
icon: SvgPicture.asset(
"",
),
onPressed: () {},
),
actions: [
IconButton(
icon: Text("Coin$ccoins"),
onPressed: () async {},
),
SizedBox(width: kDefaultPaddin / 1)
],
);
}
}`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.