Dev/delivery 85881/android delegate to singleton instance#433
Open
pazlavi wants to merge 4 commits intodevelopmentfrom
Open
Dev/delivery 85881/android delegate to singleton instance#433pazlavi wants to merge 4 commits intodevelopmentfrom
pazlavi wants to merge 4 commits intodevelopmentfrom
Conversation
* SDK updates deprecate V1 purchase validation, improve iOS error handling (#429) * SDK updates deprecate V1 purchase validation, improve iOS error handling SDK Version Updates: - Update Android SDK from 6.17.4 to 6.17.5 - Update iOS SDK from 6.17.7 to 6.17.8 - Update iOS Purchase Connector from 6.17.7 to 6.17.8 - Bump plugin version to 6.17.8 across all platforms API Changes: - Deprecate validateAndLogInAppAndroidPurchase (V1) - Deprecate validateAndLogInAppIosPurchase (V1) - Enhance iOS error handling for validateAndLogInAppPurchaseV2 with NSError parsing (code, domain, userInfo) Documentation Updates: - Remove "Beta" label from validateAndLogInAppPurchaseV2 API - Mark V1 purchase validation APIs as Deprecated - Add comprehensive PlatformException error handling examples - Add iOS token format explanation for uninstall measurement - Add cross-platform Firebase Messaging example for uninstall tokens * lint * CHANGELOG update * fix implementation for validateAndLogInAppPurchaseV2 * fix: remove toJSON() causing extra quotes in PR creation * fix: add .pubignore and handle RC dry-run warnings gracefully * lint * chore: prepare RC (iOS 6.17.8, Android 6.17.5)
Version in pubspec.yaml was incorrectly merged with RC suffix. This fixes the version to be production-ready.
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.
Fix: Plugin Instance Recreation on App Background/Foreground
Summary
This PR fixes an issue where a new
AppsflyerSdkPlugininstance was created when the app went to background (via back button) and returned to foreground. This caused loss of plugin state, callbacks, and potential issues with deep linking and conversion data.Problem
When the Android app goes to background using the back button and returns to foreground, Flutter's engine may be recreated, which causes Flutter to instantiate a new plugin instance. This resulted in:
Solution
Implemented a Delegate + Singleton pattern:
AppsflyerSdkPluginDelegate(new) - A lightweight delegate class that Flutter instantiates. It forwards all calls to the singleton implementation.AppsflyerSdkPlugin(modified) - Now a singleton that holds all plugin state and logic. Ensures the same instance is reused across engine recreations.PluginLogger(new) - Utility class for controlled debug logging via system property or programmatically.Changes
New Files
AppsflyerSdkPluginDelegate.java- Delegate entry point for Flutter plugin registrationPluginLogger.java- Debug logging utility with system property controlModified Files
AppsflyerSdkPlugin.java- Converted to singleton pattern, added extensive debug loggingpubspec.yaml- Updated AndroidpluginClasstoAppsflyerSdkPluginDelegateArchitecture
Debug Logging
Debug logging can be enabled in two ways:
1. Via ADB (requires app restart)
adb shell setprop debug.appsflyer.flutter true2. Automatically with SDK debug mode
When
isDebug: trueis passed toinitSdk(), plugin logging is automatically enabled.3. Programmatically
Log Output Examples
When enabled, logs show the singleton pattern working:
Testing
Checklist