Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
✨ Added support for placements
Browse files Browse the repository at this point in the history
  • Loading branch information
nixxxon authored and vegidio committed Dec 28, 2020
1 parent d0f18ba commit 09b9367
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 101 deletions.
2 changes: 2 additions & 0 deletions ios/.swiftformat → .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
--enable emptyBraces
--enable initCoderUnavailable
--enable isEmpty
--enable isEmpty
--enable leadingDelimiters
--enable numberFormatting
--enable preferKeyPath
Expand Down Expand Up @@ -42,6 +43,7 @@
--enable spaceInsideComments
--enable spaceInsideGenerics
--enable spaceInsideParens
--enable spaceInsideParens
--enable todos
--enable trailingCommas
--enable wrapEnumCases
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.0

* Added support for placements (thanks [@nixxxon](https://github.com/nixxxon) & [@debaserr](https://github.com/debaserr)).

## 0.4.1

* Upgraded Appodeal library to version 2.8.1 (thanks [@debaserr](https://github.com/debaserr)).
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ Center(

### Interstitial, Reward & Non-Skippable ads

To show an interstitial, reward or non-skippable ad, call the function `Appodeal.show()` passing the type of ad that you would like to show as a paremeter:
To show an interstitial, reward or non-skippable ad, call the function `Appodeal.show()` passing the type of ad that you would like to show as a paremeter (mandatory) and the [placement name](https://faq.appodeal.com/en/articles/1154394-placements) (optional):

```dart
Appodeal.show(AdType.INTERSTITIAL); // Show an interstitial ad
Appodeal.show(AdType.REWARD); // Show a reward ad
Appodeal.show(AdType.NON_SKIPPABLE); // Show a non-skippable ad
Appodeal.show(AdType.INTERSTITIAL, placementName: "placement-name"); // Show an interstitial ad
Appodeal.show(AdType.REWARD, placementName: "placement-name"); // Show a reward ad
Appodeal.show(AdType.NON_SKIPPABLE, placementName: "placement-name"); // Show a non-skippable ad
```

## ♻️ Callbacks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@ import io.flutter.plugin.platform.PlatformViewFactory
class AppodealBannerFactory(private val activity: Activity, private val messenger: BinaryMessenger) :
PlatformViewFactory(StandardMessageCodec.INSTANCE) {
override fun create(context: Context?, viewId: Int, args: Any?): PlatformView =
AppodealBannerView(activity, messenger, viewId)
AppodealBannerView(activity, messenger, viewId, args)

class AppodealBannerView(activity: Activity, messenger: BinaryMessenger, id: Int) :
class AppodealBannerView(activity: Activity, messenger: BinaryMessenger, id: Int, args: Any?) :
PlatformView, MethodChannel.MethodCallHandler {
private val arguments = args as Map<*, *>
private val placementName = arguments["placementName"] as? String

private val bannerView = Appodeal.getBannerView(activity)
private val channel = MethodChannel(messenger, "plugins.io.vinicius.appodeal/banner_$id")

init {
Appodeal.show(activity, Appodeal.BANNER_VIEW)
if (placementName !== null) {
Appodeal.show(activity, Appodeal.BANNER_VIEW, placementName)
} else {
Appodeal.show(activity, Appodeal.BANNER_VIEW)
}

channel.setMethodCallHandler(this)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AppodealFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
"setAutoCache" -> setAutoCache(call, result)
"cache" -> cache(call, result)
"isReadyForShow" -> isReadyForShow(call, result)
"canShow" -> canShow(call, result)
"show" -> show(activity, call, result)

// Consent Manager
Expand Down Expand Up @@ -110,11 +111,28 @@ class AppodealFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
result.success(Appodeal.isLoaded(adType))
}

private fun canShow(call: MethodCall, result: Result) {
val args = call.arguments as Map<*, *>
val adType = getAdType(args["adType"] as Int)
val placementName = args["placementName"]

if (placementName !== null) {
result.success(Appodeal.canShow(adType, placementName as String))
} else {
result.success(Appodeal.canShow(adType))
}
}

private fun show(activity: Activity, call: MethodCall, result: Result) {
val args = call.arguments as Map<*, *>
val adType = getAdType(args["adType"] as Int)
val placementName = args["placementName"]

result.success(Appodeal.show(activity, adType))
if (placementName !== null) {
result.success(Appodeal.show(activity, adType, placementName as String))
} else {
result.success(Appodeal.show(activity, adType))
}
}
// endregion

Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ PODS:
- Protobuf (~> 3.12)
- StackIAB (~> 1.1.2)
- StackModules (~> 1.0.2)
- appodeal_flutter (0.4.1):
- appodeal_flutter (0.5.0):
- APDAdColonyAdapter (= 2.8.1.1)
- APDAmazonAdsAdapter (= 2.8.1.1)
- APDAppLovinAdapter (= 2.8.1.1)
Expand Down Expand Up @@ -337,7 +337,7 @@ SPEC CHECKSUMS:
APDYandexAdapter: 174764c7adc6ae27556f613508b5b544d438583d
AppLovinSDK: c307abff8023aa4776f863226cbe42e7a90b3364
Appodeal: bf9748c013eb1e91d973391130fab386ef947779
appodeal_flutter: 25584b67cfc516ca2f9df8bdba3b0f5bb1214f51
appodeal_flutter: 41c2a1e01fbc31679792b05f31779ae519833861
AppRollSDK: bd9e96ad026dd51ad07714a35d43da95bb882d5f
BidMachine: 5c9659e41640613d0882a6e5f352914fdaac2a31
CriteoPublisherSdk: a7551daf9235203a040703504ae549e842b5eebf
Expand Down Expand Up @@ -367,4 +367,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: fe0e1ee7f3d1f7d00b11b474b62dd62134535aea

COCOAPODS: 1.9.3
COCOAPODS: 1.10.0
18 changes: 0 additions & 18 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
buildPhases = (
110F7A9EFDF7B90F6F32FAF4 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
3355360B779AB417636D2A18 /* [CP] Prepare Artifacts */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
Expand Down Expand Up @@ -221,23 +220,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3355360B779AB417636D2A18 /* [CP] Prepare Artifacts */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-artifacts-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Prepare Artifacts";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-artifacts-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-artifacts.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import Flutter
import UIKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate
{
override func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Expand Down
14 changes: 11 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class _Body extends StatelessWidget {
RaisedButton(
child: Text('Show Interstitial Ad'),
onPressed: () async {
await Appodeal.show(AdType.INTERSTITIAL);
await Appodeal.show(AdType.INTERSTITIAL, placementName: "placement-name");
},
),
RaisedButton(
Expand All @@ -119,7 +119,7 @@ class _Body extends StatelessWidget {
RaisedButton(
child: Text('Show Reward Ad'),
onPressed: () async {
var status = await Appodeal.show(AdType.REWARD);
var status = await Appodeal.show(AdType.REWARD, placementName: 'placement-name');
print(status);
},
),
Expand All @@ -131,14 +131,22 @@ class _Body extends StatelessWidget {
duration: Toast.LENGTH_LONG, gravity: Toast.BOTTOM);
},
),
RaisedButton(
child: Text('Can Show Non-Skippable Ad?'),
onPressed: () async {
var canShow = await Appodeal.canShow(AdType.NON_SKIPPABLE, placementName: "placement-name");
Toast.show(canShow ? 'Non-Skippable can be shown' : 'Non-Skippable can NOT be shown', context,
duration: Toast.LENGTH_LONG, gravity: Toast.BOTTOM);
},
),
RaisedButton(
child: Text('Show Non-Skippable Ad'),
onPressed: () async {
var status = await Appodeal.show(AdType.NON_SKIPPABLE);
print(status);
},
),
AppodealBanner()
AppodealBanner(placementName: "placement-name"),
],
),
),
Expand Down
40 changes: 20 additions & 20 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,49 @@ packages:
path: ".."
relative: true
source: path
version: "0.4.1"
version: "0.5.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.3"
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0-nullsafety.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.5"
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.5"
version: "1.15.0-nullsafety.3"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -63,7 +63,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.2.0-nullsafety.1"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -80,21 +80,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.3"
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.6"
version: "1.3.0-nullsafety.3"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.3"
version: "1.8.0-nullsafety.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -106,42 +106,42 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.4"
version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.6"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.6"
version: "0.2.19-nullsafety.2"
toast:
dependency: "direct main"
description:
Expand All @@ -155,14 +155,14 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.5"
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.5"
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.20.0 <2.0.0"
Loading

0 comments on commit 09b9367

Please sign in to comment.