ray_sigmob_ads 0.1.0
ray_sigmob_ads: ^0.1.0 copied to clipboard
Sigmob ads for Flutter with rewarded, interstitial, and splash formats on Android and iOS.
ray_sigmob_ads #
Flutter plugin for Sigmob ads on Android and iOS. It bundles Sigmob Android SDK 4.25.81 and iOS SDK 5.1.2.
Supported features:
- SDK initialization, startup, version query, and debug logging
- Privacy and consent configuration
- Rewarded video
- New interstitial
- Splash ads
- Global and per-ad lifecycle event streams
- Structured synchronous and asynchronous errors
Requirements #
- Flutter 3.44 or newer
- Dart 3.12 or newer
- Android API 24 or newer
- iOS 13 or newer
Installation #
Add the package to pubspec.yaml:
dependencies:
ray_sigmob_ads: ^0.1.0
Then run flutter pub get.
Initialize #
Initialize only after the user accepts your privacy policy. Values in
SigmobPrivacyConfig must reflect the user's actual choices.
await FlutterSigmob.initialize(
const SigmobConfig(
appId: 'your-app-id',
appKey: 'your-app-key',
debug: false,
privacy: SigmobPrivacyConfig(
allowLocation: false,
allowOaid: false,
allowAndroidId: false,
allowAppList: false,
allowSimOperator: false,
allowIdfa: false,
allowIdfv: false,
allowMotion: false,
allowDiskSpace: false,
personalizedAdvertising: false,
programmaticAdvertising: false,
),
),
);
await FlutterSigmob.start();
initialize and start are idempotent. On iOS, initialization starts the
native SDK and the following start is retained as a cross-platform no-op.
Listen for events #
Subscribe before loading an ad so that no lifecycle event is missed:
final subscription = FlutterSigmob.events.listen((event) {
if (event.type == SigmobAdEventType.loadFailed ||
event.type == SigmobAdEventType.showFailed) {
debugPrint('${event.error?.code}: ${event.error?.message}');
}
});
Important events include:
| Event | Meaning |
|---|---|
serverResponse |
Server responded; data['isFillAd'] indicates fill |
loaded |
Material is ready and the ad may be shown |
loadFailed |
Load failed; inspect event.error |
shown / showFailed |
Presentation succeeded or failed |
clicked |
User clicked the ad |
rewarded |
Reward result is in data['isRewarded'] |
closed |
Ad closed; release or reload it |
Rewarded video #
final ad = SigmobRewardedAd(
request: const SigmobAdRequest(
placementId: 'your-rewarded-placement-id',
userId: 'your-user-id',
options: <String, String>{'order_id': '42'},
),
);
final subscription = ad.events.listen((event) {
if (event.type == SigmobAdEventType.rewarded &&
event.data['isRewarded'] == true) {
// Grant the reward according to your server and product rules.
}
});
await ad.load();
// Wait for SigmobAdEventType.loaded.
if (await ad.isReady) {
await ad.show(sceneId: 'daily-reward');
}
await subscription.cancel();
await ad.dispose();
New interstitial #
final ad = SigmobInterstitialAd(
request: const SigmobAdRequest(
placementId: 'your-interstitial-placement-id',
),
);
await ad.load();
// Wait for SigmobAdEventType.loaded.
if (await ad.isReady) {
await ad.show(sceneId: 'level-finished');
}
await ad.dispose();
Splash #
final ad = SigmobSplashAd(
request: const SigmobAdRequest(
placementId: 'your-splash-placement-id',
),
fetchDelaySeconds: 5,
);
await ad.load();
// Wait for SigmobAdEventType.loaded.
if (await ad.isReady) {
await ad.show();
}
await ad.dispose();
The native splash view is mounted full-screen and removed after a failure, closure, or explicit disposal.
Error handling #
Immediate method-channel failures throw SigmobException. Asynchronous native
ad failures arrive as SigmobAdEvent.error:
try {
await ad.load();
} on SigmobException catch (error) {
debugPrint('${error.code}: ${error.message}');
}
Input validation may throw ArgumentError; using an ad after disposal or
showing it before load throws StateError.
Android setup #
The plugin declares only:
android.permission.INTERNETandroid.permission.ACCESS_NETWORK_STATE
Add optional sensitive permissions to the host app only when required, disclosed in your privacy policy, and accepted by the user. The bundled AARs are exposed through the plugin's local Maven repository for Android Gradle Plugin compatibility.
iOS setup #
The plugin bundles WindSDK, WindFoundation, and NexaX XCFrameworks.
When IDFA is enabled, add a meaningful ATT description to the host
application's ios/Runner/Info.plist:
<key>NSUserTrackingUsageDescription</key>
<string>用于提供更相关的广告并衡量广告效果。</string>
Request ATT authorization in the host app before initializing Sigmob. If authorization is not granted, iOS returns the zero IDFA. Also provide host-app usage descriptions for any other enabled sensitive capability, such as location. Do not add broad App Transport Security exceptions unless required by your creatives and security review.
For physical-device builds, configure a unique bundle identifier and your own Apple development team.
Release checklist #
Before shipping:
- Replace all demo App IDs, App Keys, and placement IDs.
- Ensure Android package name and iOS bundle ID match the Sigmob console.
- Confirm privacy values and native permission descriptions.
- Disable
debugand native debug logging. - Test fill, load failure, show failure, close, and reward paths on real devices.
- Build both release targets:
flutter analyze
flutter test
flutter build apk --release
flutter build ios --release
The complete runnable integration is in example/.
Licensing #
Plugin source is MIT licensed. Bundled SDK notices are in
THIRD_PARTY_NOTICES.md.