I'm having issues setting up push notifications for iOS on Flutter.
Another dev tried adding too - had the same problem.
TL;DR: Can anyone get pushes running on iOS Flutter with clean new build from stable channel?
I followed setup steps described here:
https://pub.dev/packages/firebase_messaging
Specifically:
Generated app ID and push Key in https://developer.apple.com/account/resources/certificates/
Added info.plist to ios/Runner folder
Turned on Push capabilities
Uploaded APNS certificate to Firebase console
Made sure bundle ID is the same in App / Runner, info.plist and GoogleService-Info.plist
Added lines in AppDelegate.swift
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
Pushes aren't coming. Neither when app in background, not at all.
I also tried another step - sending individual push. Send code in CURL looks like this:
curl -i -X POST \
-H "Content-Type:application/json" \
-H "Authorization:key=AIza_legacy_key" \
-d \
'{
"to": "my_push_token",
"notification":
{"body": "test_body",
"title": "test_title"
},
"priority": "high",
}
' \
'https://fcm.googleapis.com/fcm/send'
And the response is always this type:
- First request is InvalidRegistration
- Second and next same calls is NotRegistered
Another person found similar problem this summer and posted on GitHub, but thread was closed:
https://github.com/flutter/flutter/issues/30486
My Flutter doctor:
[✓] Flutter (Channel unknown, v1.12.13+hotfix.7, on Mac OS X 10.15.3 19D76, locale ru-UA)
• Flutter version 1.12.13+hotfix.7 at /Users/reiven/flutter
• Framework revision 9f5ff2306b (2 weeks ago), 2020-01-26 22:38:26 -0800
• Engine revision a67792536c
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/reiven/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio 3.6 Preview.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.7.5
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio 3.6 Preview.app/Contents
• Flutter plugin version 43.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (4 available)
• iPhone • 96c120610d684dbab7f5e4d036a7f48041755f96 • ios • iOS 12.3.1
• iPhone 11 Pro Max • 8ABC99D3-6C46-4A3D-968B-F5719AA92C97 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• Chrome • chrome • web-javascript • Google Chrome 79.0.3945.130
• Web Server • web-server • web-javascript • Flutter Tools
p.s. Some things I've tried:
Used another developer account (100% confirmed pushes are working on another project)
Used another Firebase account
Recreated certificates, projects
Gave to try another developer to setup pushes his own (he also confirmed to be successfull in the past).
Magically things just started working yesterday evening.
So first - just try now. If not working - recreate certificates and redo initialization steps. If still not working - pray and retry another day.
Related
Recently I've joined a project of a flutter app using firebase, and everything was fine until it comes to make the production builds. For Android it works fine. But for ios I'm facing a problem that in the simulator it runs without a problem but when I uploaded it to Testflight for my coworkers to test it immediately crashes when opened.
That's my flutter doctor -v:
[✓] Flutter (Channel unknown, 2.2.2, on macOS 11.2.3 20D91 darwin-x64, locale
pt-BR)
• Flutter version 2.2.2 at /Users/leonardofelix/flutter
• Framework revision d79295af24 (4 months ago), 2021-06-11 08:56:01 -0700
• Engine revision 91c9fc8fe0
• Dart version 2.13.3
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/leonardofelix/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.61.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.27.0
[✓] Connected device (2 available)
• iPhone 12 Pro Max (mobile) • 94BE45CC-ED04-4892-B3A6-3F43D0A147AD • ios
• com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
• Chrome (web) • chrome •
web-javascript • Google Chrome 94.0.4606.81
And the crash report that a tester of testflight sent to me:
crashlog.crash
I've already tested some things that I found googling, like add the Google-Services.plist again using xcode and verified if the schemas to the archive were pointing to release mode. But none of them worked.
If any additional data is needed, I'll be glad to provide. So thanks in advance for any help.
Well, I found the error. I had changed the Flutter version using git (thus, the Flutter folder is a git repository). When I changed the version, it left the cache from the other Flutter version, and that cache was causing the problem.
One thing that helped me to find this out was running the release build in a physical device using Xcode; there it prompt me the following error:
Error while initializing the Dart VM: Wrong full snapshot version, expected '9cf77f4405212c45daf608e1cd646852' found 'e4a09dbf2bb120fe4674e0576617a0dc'
And for that, I found a solution on the web. What I did was to remove the folder cache inside <yourFlutterDir>/bin and run the following commands in the Flutter directory:
git reset --hard
git clean -xffd
flutter doctor
And then, I went to my Flutter project folder, ran flutter clean, and finally flutter build ios.
So the project built successfully, and the app worked in iOS.
So, yesterday I build an app for ios, archive it and upload it to AppStore connect through xcode, everything seemed good but after few moments I received an email from apple saying:
Dear Developer,
We identified one or more issues with a recent delivery for your app, "APP-NAME" 1.0.1 (2). Please correct the following issues, then upload again.
ITMS-90755: Invalid Binary - The following binaries in your app contains prohibited instructions: /Volumes/data01/app_data/awf/SWImportWorker-mr47p00ce-swpr0068.cse.apple.com-300252/ff03-SoftwareImportWorker-MR_.0/NYH74E2GDJSTMWPVXUPB4IZWH4/umuagyjihbsjsrpn/wspvjpsuvltmmknh/Payload/Runner.app/Frameworks/App.framework/App. Remove the instructions from the binaries, rebuild and resubmit.
Best regards,
The App Store Team
I tried again with flutter clean and also increased the IOS deployment target but it didn't help.
My device's Flutter info:
Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-x64, locale
en-PK)
• Flutter version 2.5.0 at /Users/niteshkongreja/Development/flutter
• Upstream repository https://github.com/niteshcongreja321/flutter.git
• Framework revision 4cc385b4b8 (10 days ago), 2021-09-07 23:01:49 -0700
• Engine revision f0826da7ef
• Dart version 2.14.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/niteshkongreja/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• ANDROID_HOME = /Users/niteshkongreja/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] VS Code (version 1.60.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.26.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 11.5.2 20G95 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.82
• No issues found!
All I had to do was revoke my certificate, delete the mobileprovision file, then recreate both.
I also changed over to Air SDK 3.7.0.1530 and included the Default-568h#2x.png for the iphone splash screen, and well... it seems to have worked.
After updating my iPhone 11 to iOS version 14.7.1, my flutter app is not launching anymore.
Steps already performed:
flutter clean
flutter pub get
flutter run
Also,
uninstalled and reinstalled the app
restarted the phone
output:
(base) Henrys-MacBook-Air:flutter henrycorreia$ flutter run
Running "flutter pub get" in flutter... 3.2s
Launching lib/main.dart on Henry’s iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: XXXXXXXXXX
Running pod install... 25.0s
Running Xcode build...
Xcode build done. 208.8s
Installing and launching... 58.4s
Error launching application on Henry’s iPhone.
==>> flutter doctor -v:
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.1 20G80 darwin-x64, locale en-GB)
• Flutter version 2.2.3 at /Users/henrycorreia/fvm/versions/2.2.3
• Framework revision f4abaa0735 (6 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/henr/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] VS Code (version 1.59.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.25.0
[✓] Connected device (3 available)
• Moto E 4 Plus (mobile) • xxxxxxxxx • android-arm • Android 7.1.1 (API 25)
• Henry’s iPhone (mobile) • xxxxxxxxxxxxxx • ios • iOS 14.7.1
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.131
! Doctor found issues in 1 category.
Is anybody facing the same issue? Any idea how to fix this?
Thank you
You have runtime error just before your first screen renders, try putting breakpoint in the first line of the main and debug line by line.
I was able to fix the issue. It seems to be a random issue that happens time to time when updating either the flutter version or iOS...
Here's how I fixed the issue:
==>> you can also get inspired by this thread: https://github.com/flutter/flutter/issues/72161
However, what worked for me was very simple as I am using vs code:
uninstalled the app
restarted the phone
open the app using Xcode
Product -> Clean Build Folder
Product -> Run
The app will launch correctly, then quit Xcode
After that, I run the app using vs code, and now it works as before.
I am receiving this message with a rejection when I submit my app for review on the App Store:
"Specifically, your app displayed a white, blank screen when we launched your app."
When I test the app on device, everything appears to be working fine. I have tried the following to test:
flutter build ios
flutter run
flutter build ios --release
flutter run
Test with VSCode's run feature.
Run in xcode onto physical device both in Debug and Release schema settings
If I archive, and upload the same build to Testflight, the app can be installed and ran without issue on several different devices.
While all of these methods work on my physical iphone, when I run
flutter build ios --release
open xcode
archive
upload with Organizer in xcode
The app is rejected by Apple. I searched around and found nothing that solves my issues. Any suggestions or good next steps?
flutter doctor:
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.1 20C69 darwin-x64, locale en-US)
• Flutter version 1.22.6 at /Users/matthewkrager/flutter
• Framework revision 9b2d32b605 (5 days ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/matthewkrager/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
✗ Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.9.1
[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1
[✓] Connected device (2 available)
I'm using Flutter with Android-Studio, everything was working great (i.e. compiling and deploying to iOS simulators except until I installed Fastlane Tools. The building process now is broken somehow! I'm not sure if it's from Fastlane or something else though, but now I'm stuck and cannot deploy to iOS anymore.
Steps taken/tried already:
Removing XCode & CommandLineTools (using this post: Complete removal old XCode)
Reinstalling XCode 9.2 (from AppStore)
Reinstalling CommandLineTools for XCode 9.2 (dl from developer tools page)
Reinstalling/updating ios-deply using:
npm install -g ios-deploy --unsafe-perm=true
Error log is on PasteBin to reduce post size:
https://pastebin.com/HQdJYLBr
Flutter doctor report:
[✓] Flutter (on Mac OS X 10.13.3 17D102, locale en-AE, channel alpha)
• Flutter version 0.0.22-pre.1 at /Users/user999/github/flutter
• Framework revision 553fc4264e (3 weeks ago), 2018-03-01 09:30:25 -0800
• Engine revision 6921873c71
• Tools Dart version 2.0.0-dev.16.0
• Engine Dart version 2.0.0-edge.da1f52592ef73fe3afa485385cb995b9aec0181a
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/user999/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.2, Build version 9C40b
• ios-deploy 1.9.2
• CocoaPods version 1.4.0
[✓] Android Studio (version 3.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] IntelliJ IDEA Community Edition (version 2017.3.4)
• Flutter plugin version 21.2.3
• Dart plugin version 173.4548.30
[✓] Connected devices
• iPhone X • 2AD97E20-6FB5-4086-BDC0-EBE6138FBD79 • ios • iOS 11.2 (simulator)
Any suggestions, please?
This answer is for the ones who are still trying to work with Xcode 9.2. Starting April, 2020, all apps submitted to the App Store will need to be built with Xcode 11. So don't try to build your Flutter IOS App with XCode 9.2.
Flutter is also changing rapidly therefore, it is better to use the latest XCode version to avoid any deprecated API issue.
For reference visit:
https://github.com/firebase/firebase-ios-sdk/issues/4125