Flutter - Debugging iOS 14 background message (when the app is closed) - flutter

Trying to build a chat app, which gets FCM messages and shows notifications even when the app is closed.
Clearly, something in my top-level onBackgroundMessage function for FCM is wrong as the notifications are not showing (on a physical device- iOS emulators don't work with FCM).
In Android, I've debugged a similar situation by using adb logcat (and logs/print command).
Obviously, adb isn't available for an iPhone, and I don't know how to see the logs after the app is closed (I've tried to look at the console at Xcode but no Flutter messages are showing).
Because I can't run the app again after it's closed (see https://docs.flutter.dev/development/ios-14 the application can no longer be re-launched by tapping the application’s icon) I'm installing it on my device via "flutter install release".
How do I see the logs after install release, or otherwise how can I debug functionality (at least view flutter's logs and prints) when the app is closed?

Related

Flutter app is not showing as an icon on the android emulator homescreen

I am trying to build an app. I am using flutter as the framework and VS Code as my IDE. I also have an android emulator installed via android studio. I am trying to implement authentication. If i run my app it opens in the emulator and works just fine. Now i want to test if a user stays logged in when the app is closed (not running in the background) and reopened. However if i close the app in the android emulator, the whole process stops and there is no icon of my app on the home screen with which i could restart it. I have to "run and debug" again in VS Code to restart the process. Is there any way to start the app again via the emulator phone?
I updated the emulator and the flutter package, i changed emulator devices. Did not solve the problem.
Because when your app is disconnected from debug - you can use hot restart its consider as app is kill and open again - here having a problem with flutter if you disconnect from debug your all assets will be remove from entire app. Another option - if you want to test your app then make release app and installed in physical device
You can try to run your app from VS Code itself.
Use this bottom Menu button to launch emulator:
Select your Emulator from listed / Create a new one:
Hope it helps!

Flutter App can't launching in iPhone without connecting to the computer?

I can build & launching app well in my iPhone when my phone is connecting to the macbook , and launching by the command line flutter run.
But when i disconnect my iPhone from the macbook . and I want to launch the app from the iPhone's desktop. the app seems can't launch , and will exit very soon.
Is there any way to launch flutter app from the iPhone's desktop?
This is happen because you are building iOS app in debug mode, run app in profile or release mode and it will fix.
Thanks for the #eamirho3ein's answer: change the debug to release fix the problem.
In fact, there is one thing to be metioned: the default config in xcode for command-line build is release already, but if you change this mode won't help. the mode needed to be change is the flutter run mode.
there are many ways to do this.

Got the "Error launching application on" after flutter run

I am flowing the official tutorial to install flutter and run the default app on my iPhone Device. After I execute the flutter run, the app is installed and launched on my iPhone but the logs show the bellow error. How do I solve it?
Launching lib/main.dart on My iPhone 6 in debug mode...
Automatically signing iOS for device deployment using specified development team
in Xcode project: XXXXXXXXXX
Running Xcode build...
└─Compiling, linking, and signing... 50.2s
Xcode builds done. 90.1s
Installing and launching... 41.1s
Error launching the application on My iPhone 6. <-- Error Here
It happens that there are some process needed to Flutter plugin correctly run on physical devices. I struggled with that and finally found that the processes idevicesyslog and iproxy were being silently blocked by MacOS.
You may have noticed already a message liked this:
or a similar one for idevicesyslog.
Once I went to System Preferences -> Security & Privacy in General tab and allowed this apps, everything works. Note that this screen shows only the last app that you tried to run. So I'd recommend that you run flutter app with preferences opened so you can (hopefully) see the messages appearing and click allow.
MacOS may warn you one more time about the file being downloaded from the internet. Just click open and you're good.
The error do not show again after reboot the iPhone.
Same error -- Running fine through Xcode, when I ran with flutter CLI, the app would open, but the terminal log output would crash with the error as in the post.
I ran flutter update and simultaneously turned iPhone off and back on. After doing that, the below popup appeared (on mac).
I believe after the install finished, I ran the below (which I ran several times before updating flutter and installing the popup):
flutter clean
rm -rf ios/Pods
flutter pub get
cd ios && pod install && cd ..
run the flutter app using flutter run from command line, then the MacBook will ask for permission to open the app and app runs,
(lldb) warning: libobjc.A.dylib is being read from process memory. This indicates that LLDB could not find the on-disk shared cache for this device. This will likely reduce debugging performance.
Error launching application on device-XXXXX.
Building & Replace with a newest version ios-deploy solved problems list aboved. Flutter SDK bundled a pre-built command ios-deploy in __PATH_TO_YOUR_Flutter_SDK_/bin/cache/artifacts/ios-deploy/, just replace it.
Please reference to: Flutter Error launching application on device issue .

Flutter 1.22.0 IOS app connection lost issue

I have migrated to Flutter 1.22.0 from the older version. When I am trying to run the application in the IOS Simulator, it just opens the app and crashes and says connection lost. However in the Android Studio, it still shows it is running, I mean the Run & Debug button is disabled but the stop button is active.
The flutter run --verbose output is here.
Following logs I am seeing at the end after that nothing happens.
Launching lib/main.dart on iPhone 11 Pro in debug mode...
Running Xcode build...
Xcode build done. 18.4s
Configuring the default Firebase app...
6.26.0 - [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
6.26.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
[Firebase/Crashlytics] Version 4.1.1
Configured the default Firebase app __FIRAPP_DEFAULT.
6.26.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60600000 started
6.26.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
6.26.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
Waiting for iPhone 11 Pro to report its views...
Debug service listening on ws://127.0.0.1:55184/qe2GMcl6YA3=/ws
Syncing files to device iPhone 11 Pro...
Lost connection to device.
Whenever I start the IOS simulator, it gives me the "Spotlight quit unexpectedly." error. See the below screenshot. Not sure whether it is related to this issue or not...
You are still using an older version of Flutter. v1.22.2 is released this week. Try to upgrade Flutter with flutter upgrade --force.

Send keyboard event from developer PC to Flutter app

When running an app via Flutter run or VC, we see the flutter console log of the app.
Is it possible to send keyboard events from the developer PC to the app via STDIN which we receive in the app (without VM extensions).
The idea is to use this during development to trigger certain actions in the app.
I ended up building a simple TELNET server into the app. This I way, I communicate with the app running on a phone for debugging purposes.