Feat/read ads setttings from flowline - #244
Merged
Merged
Conversation
feat: admob settings added to manage internal ads
There was a problem hiding this comment.
Pull request overview
This PR introduces Flowline-provided ad settings storage/reading so the app can disable AdMob dynamically (e.g., “general” or per-timezone), and updates app/package versions accordingly.
Changes:
- Bump app and MSIX versions.
- Persist Flowline
settingsinto secure storage and expose them via a newgetFlowlineSettings()API. - Update ad-environment/ad-selection logic to use Flowline settings + timezone instead of the previous Iran-only heuristic.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pubspec.yaml | Version bump for the app release. |
| lib/core/data/local/secure_storage/secure_storage_const.dart | Adds a secure-storage key for Flowline settings. |
| lib/core/data/local/remote/api/flowline_settings.dart | New model representing Flowline ad-related settings. |
| lib/core/data/local/remote/api/flowline_service.dart | Writes Flowline settings to storage; adds getFlowlineSettings(). |
| lib/core/data/local/remote/api/flowline_service_interface.dart | Extends service interface to return FlowlineSettings. |
| lib/app/app.dart | Adjusts ad-init debug logging to use renamed environment fields. |
| lib/app/advertise_director.dart | Ad strategy selection now uses Flowline settings + timezone. |
| lib/app/ad_director_provider.dart | Renames environment flag and uses it to decide AdMob initialization. |
| ios/Podfile.lock | Updates iOS Firebase-related pods and CocoaPods lock metadata. |
Suppressed comments (2)
lib/core/data/local/remote/api/flowline_service.dart:126
json.decode(settingsString ?? "")will throw aFormatExceptionwhen the key is missing/empty, which can break app startup. Since the value is stored viawriteMap, preferreadMapwhich already handles missing/invalid values gracefully.
Future<FlowlineSettings> getFlowlineSettings() async {
final settingsString = await _secureStorage.read(flowlineSettingsKey);
final decodedSettings = json.decode(settingsString ?? "");
return FlowlineSettings.fromJson(decodedSettings);
lib/app/advertise_director.dart:27
shouldUseInternalAdsfetches Flowline settings and timezone before the desktop short-circuit, and without error handling. If settings aren't cached yet (or storage is empty/corrupt), this can throw and break environment initialization. Check desktop first and wrap settings/timezone reads in a try/catch with a safe default.
final flowlineSettings = await ref
.read(flowlineServiceProvider)
.getFlowlineSettings();
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
89
to
+92
| final advertiseStorageMap = {'api_advertise': decoded['advertise']}; | ||
| final settingsStorageMap = decoded['settings']; | ||
| await _secureStorage.writeMap(apiAvertiseKey, advertiseStorageMap); | ||
| await _secureStorage.writeMap(flowlineSettingsKey, settingsStorageMap); |
Comment on lines
+1
to
+12
| class FlowlineSettings { | ||
| List<String> disabledAdmob; | ||
|
|
||
| FlowlineSettings({required this.disabledAdmob}); | ||
|
|
||
| factory FlowlineSettings.fromJson(Map<String, dynamic> json) { | ||
| List<String> disabledAdmob = List<String>.from(json["disabledAdmob"]); | ||
| disabledAdmob = disabledAdmob.map((v) => v.toLowerCase()).toList(); | ||
|
|
||
| return FlowlineSettings(disabledAdmob: disabledAdmob); | ||
| } | ||
| } |
| import 'package:defyx_vpn/core/data/local/remote/api/flowline_service.dart'; | ||
| import 'package:defyx_vpn/core/data/local/secure_storage/secure_storage.dart'; | ||
| import 'package:defyx_vpn/core/data/local/secure_storage/secure_storage_const.dart'; | ||
| import 'package:defyx_vpn/modules/core/log.dart'; |
Comment on lines
28
to
30
| String toString() => | ||
| 'AdEnvironment(isIranian: $isIranian, isMobile: $isMobilePlatform, initAdMob: $shouldInitializeAdMob)'; | ||
| 'AdEnvironment(isIranian: $adMobIsDisabled, isMobile: $isMobilePlatform, initAdMob: $shouldInitializeAdMob)'; | ||
| } |
Comment on lines
47
to
49
| debugPrint( | ||
| '📱 Using internal ads only (${environment.isIranian ? "Iranian user" : "desktop platform"})', | ||
| '📱 Using internal ads only (${environment.adMobIsDisabled ? "Iranian user" : "desktop platform"})', | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
Briefly describe what this PR does and why. Keep it short and clear.
Related Platforms
Verification Checklist
Optional (for bigger changes)
Related Links
Closes #ID.