I am trying to implement silent push notification support using firebase_messaging package.
In general, things works pretty well except fo one specific case: after iOS app has been terminated by user and a new silent push notification is sent, the app is launched but gets very little execution time before immediately being suspended.
Every subsequent push notification results in the app getting a bit more execution time. Eventually, all notifications arrive, but only as a result of a few push notifications being sent, the app then getting sufficient execution time and hence firebase_messaging getting completely initialized.
Obviously, the app has "Background Fetch" and "Remote notifications" flags enabled.
Any help on solving this will be very much appreciated.
HI @leonidl
Tested official example with app terminated, sent silent notifications and all notification arrive one at a time on iPhone XR
flutter doctor -v
[β] Flutter (Channel dev, 1.20.0-1.0.pre, on Mac OS X 10.15.5 19F101, locale
en-GB)
β’ Flutter version 1.20.0-1.0.pre at /Users/tahatesser/Code/flutter_dev
β’ Framework revision f73f498da1 (4 days ago), 2020-06-18 08:23:22 -0700
β’ Engine revision c0d52b98d1
β’ Dart version 2.9.0 (build 2.9.0-16.0.dev 2b917f5b6a)
[β] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
β’ Android SDK at /Users/tahatesser/Code/sdk
β’ Platform android-29, build-tools 29.0.3
β’ ANDROID_HOME = /Users/tahatesser/Code/sdk
β’ 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-6222593)
β’ All Android licenses accepted.
[β] Xcode - develop for iOS and macOS (Xcode 11.5)
β’ Xcode at /Applications/Xcode.app/Contents/Developer
β’ Xcode 11.5, Build version 11E608c
β’ CocoaPods version 1.9.3
[β] Chrome - develop for the web
β’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[β] Android Studio (version 4.0)
β’ Android Studio at /Applications/Android Studio.app/Contents
β’ Flutter plugin version 46.0.2
β’ Dart plugin version 193.7361
β’ Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
[β] VS Code (version 1.46.1)
β’ VS Code at /Applications/Visual Studio Code.app/Contents
β’ Flutter extension version 3.11.0
[β] Connected device (5 available)
β’ SM M305F β’ 32003c30dc19668f β’ android-arm64 β’ Android 10
(API 29)
β’ Tahaβs iPhone β’ 00008020-001059882212002E β’ ios β’ iOS 13.5.1
β’ macOS β’ macOS β’ darwin-x64 β’ Mac OS X
10.15.5 19F101
β’ Web Server β’ web-server β’ web-javascript β’ Flutter Tools
β’ Chrome β’ chrome β’ web-javascript β’ Google Chrome
83.0.4103.106
β’ No issues found!
Can you please provide your flutter doctor -v your flutter run --verbose and a complete reproducible minimal code sample
Thank you
Hello @TahaTesser,
It appears I am getting notifications, but the execution time allocated to the app with each notification is very short (less than a second). As a result, my app does not have enough time to load itself properly and is only able to finish loading after a few notifications. My assumption was that each notification would provide about 30 seconds of execution time, but I am not seeing that.
Here is the output of flutter doctor -v:
leonid@leonidl-mbp10 phonerings % flutter doctor -v
[β] Flutter (Channel beta, 1.19.0-4.1.pre, on Mac OS X 10.15.5 19F101, locale en-CA)
β’ Flutter version 1.19.0-4.1.pre at /Users/leonid/work/flutter
β’ Framework revision f994b76974 (3 weeks ago), 2020-06-09 15:53:13 -0700
β’ Engine revision 9a28c3bcf4
β’ Dart version 2.9.0 (build 2.9.0-14.1.beta)
[β] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
β’ Android SDK at /Users/leonid/Library/Android/sdk
β’ Platform android-29, build-tools 29.0.3
β’ ANDROID_HOME = /Users/leonid/Library/Android/sdk
β’ Java binary at: /Applications/Android Studio.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.5)
β’ Xcode at /Applications/Xcode.app/Contents/Developer
β’ Xcode 11.5, Build version 11E608c
β’ CocoaPods version 1.8.4
[β] 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.app/Contents
β’ Flutter plugin version 46.0.1
β’ Dart plugin version 192.8052
β’ Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[β] VS Code (version 1.46.1)
β’ VS Code at /Applications/Visual Studio Code.app/Contents
β’ Flutter extension version 3.12.0
[β] Connected device (5 available)
β’ Pixel 2 β’ HT84B1A02508 β’ android-arm64 β’ Android 10 (API 29)
β’ SM G973F β’ RF8M331TCFN β’ android-arm64 β’ Android 10 (API 29)
β’ iPhone8lla β’ 81fef7a65c8ca2e9b4fa26e6d69f4dcc5b1ca82a β’ ios β’ iOS 13.5.1
β’ Web Server β’ web-server β’ web-javascript β’ Flutter Tools
β’ Chrome β’ chrome β’ web-javascript β’ Google Chrome 83.0.4103.116
β’ No issues found!
I currently am not able to attach a reproducible code.
Thank you,
Leo
after iOS app has been terminated by user and a new silent push notification is sent, the app is launched but gets very little execution time before immediately being suspended.
Hey sorry for asking this here. But I'm struggling to get firebase silent notifications(data-only firebase push) to work on iOS when the app is terminated by the user.
How did you manage to get this behavior? Even the flutterfire documentation says the terminated state is not supported.
@leonidl
@krishnakumarcn
The behaviour has been hit and miss, depending on the APN flags in push notification.
I guess, it is hard to rely on this behaviour being consistent, there I was forced to redesign the handling of push notifications.
Apple has said that starting from iOS 13 they will not allow background notifications with the highest priority (10), so I don't think we can rely on background notifications arriving in time in any case.