crosspromote 0.2.0
crosspromote: ^0.2.0 copied to clipboard
Framework-agnostic, minimal dependencies, and pure Dart package for implementing CrossPromote in your project.
CrossPromote - Dart #
CrossPromote package compatible with Dart.
Caution
This package contains base Dart implementation only. Prefer using crosspromote_flutter for Flutter apps and crosspromote_jaspr for Jaspr websites.
crosspromote is a pure Dart package that connects to the CrossPromote API.
Other implementations include:
Getting started #
-
Create an account on CrossPromote and top it up.
-
Create your first ad, assign it to a an ad set, and create a new app.
-
Copy your app's identifier (it's visible under your app's name in the dashboard).
-
Add this package to your dependencies.
dependencies:
crosspromote: latest_version
- Get the dependencies.
dart pub get
- Use the
CrossPromoteClientto retrieve ads:
// Create a new client.
final client = new CrossPromoteClient(
// Replace with your app's identifier from CrossPromote.
appId: 'example.image',
);
// Fetch an ad.
final ad = await client.retrieve(
size: AdSize.w300h250,
match: AdMatch.preferredSize,
);
// One of the following: `image`, `metadata`, `empty`.
print(ad.type);
// An URL that redirects to a page specified in the console.
// This URL is a special variant that also tracks the number of clicks.
print(ad.targetUrl);
// Custom JSON payload specified in the console.
print(ad.payload);
// Properties available only for ads with type `image`.
if (ad.type == AdType.image) {
print(ad.imageUrl);
print(ad.size);
}
Additional information #
- You can use predefined identifiers to test your app during development, and avoid incurring cost during testing. Use
example.imageas your app id to display a placeholder image, orexample.metadatafor metadata ad. - This package requires Dart 3.8 or newer to work.
- If there are any issues feel free to go to GitHub Issues and report a bug.