-
-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: flutter.baseflow.com/geolocator_updates_android. #1382
Comments
Dear @gujjar1988, Thanks for filing this issue. Can you elaborate a bit on the subject? Can you add some clear steps to reproduce and add the contents of your manifest file? Kind regards, |
|
Can you reproduce this in the example app too? Kind regards, |
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
// If you're going to use other Firebase services in the background, such as Firestore,
// make sure you call `initializeApp` before using other Firebase services.
// await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
if (kDebugMode) print("Handling a background message: ${message.messageId}");
if (Platform.isAndroid) {
String type = message.data['type'];
if (type.isNotEmpty) {
final SharedPreferences prefs = await SharedPreferences.getInstance();
List<String> savedList = prefs.getStringList(StorageEnum.backgroundRemoteMessage.name) ?? [];
savedList.add(type);
await prefs.setStringList(StorageEnum.backgroundRemoteMessage.name, savedList);
if (kDebugMode) print("${message.messageId} saved in DB.");
}
} else {
message.checkAction();
}
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await ApplicationState.instance.initialize();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
RemoteConfig.setDefaults();
AppApiManager.instance.startNetworkListener();
SecureStorage.instance.box = GetStorage("MyStorage");
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]).then((value) => runApp(const MyApp()));
} |
I Have exacly the same issue |
Can you share detailed steps to reproduce? Kind regards, |
Hello, @TimHoogstrate I believe that this problem is related to the life cycle of the application, probably there must be some call native to onDestroy for the flutter that is not managing to be delivered and is therefore being imprisoned in the execution pile. I have a similar problem in my app and removing this call from onDestroy was solved, basically when the application is killed, flutter engine becomes detatched and the methodChannel can no longer be accessed. Just start app, and make some calls to geolocator and close, the issue will happen on console |
Thank you for adding the additional information. We have labelled the issue as a bug and added it to our backlog. |
@mvanbeusekom Any update on this? |
Please check the following before submitting a new issue.
Please select affected platform(s)
Steps to reproduce
I want location updates in app terminated state
Expected results
location streaming on app terminated state
Actual results
Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: flutter.baseflow.com/geolocator_updates_android.
Code sample
Code sample
Screenshots or video
Screenshots or video demonstration
[Upload media here]
Version
10.1.0
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: