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
[firebase_messaging]: android.os.MessageQueue.nativePollOnce (Native method) #12684
Comments
Helo @TarekkMA |
Could you please provide details on the payload you are using with firebase-admin, as well as the method you are employing to send these messages? This information will help us reproduce and diagnose the issue effectively. Thank you! |
@TarekkMA I can't share the structure I normally use with you. However, I'm experiencing the same issue even when I push with Postman |
@kdrgrgn, Can you use An example script can be as follows: // 0. install firebase-admin via npm
var admin = require('firebase-admin');
// 1. Download a service account key (JSON file) from your Firebase console and add to the example/scripts directory
var serviceAccount = require('./key.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
// 2. Copy the token for your device that is printed in the console on app start (`flutter run`) for the FirebaseMessaging example
const androidToken = 'token here';
// 3. From your terminal run `npm install`.
// 4. Run the script using node and your app will receive messages in any state; foreground, background, terminated.
// If you find your messages have stopped arriving, it is extremely likely they are being throttled by the platform. iOS in particular
// are aggressive with their throttling policy.
admin
.messaging()
.send(
{
token: androidToken,
data: {
foo: 'bar',
float: '12034'
},
notification: {
title: 'A great title',
body: 'Great content',
},
android: {
// Required for background/terminated app state messages on Android
priority: 'high',
},
apns: {
payload: {
aps: {
// Required for background/terminated app state messages on iOS
contentAvailable: true,
},
},
},
},
)
.then((res) => {
if (res.failureCount) {
console.log('Failed', res.results[0].error);
} else {
console.log('Success');
}
})
.catch((err) => {
console.log('Error:', err);
}); |
Hey @kdrgrgn. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Since there haven't been any recent updates here, I am going to close this issue. @kdrgrgn if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
Is there an existing issue for this?
Which plugins are affected?
Messaging
Which platforms are affected?
Android
Description
Flutter Doctor
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.0 23A344 darwin-x64, locale tr-TR)
• Flutter version 3.19.6 on channel stable at /Users/benpetto/flutter_projects/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (5 days ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/benpetto/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A240d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.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 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.88.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.86.0
[✓] VS Code (version 1.78.1)
• VS Code at /Users/benpetto/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.86.0
[✓] Connected device (5 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 14 (API 34) (emulator)
• macOS (desktop) • macos • darwin-x64 • macOS 14.0 23A344 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.61
[✓] Network resources
• All expected network resources are available.
• No issues found!
Issue:
When a notification is sent while the application is in the foreground, it crashes with the android.os.MessageQueue.nativePollOnce (Native method) error.
There is no issue with the first notification; it arrives promptly. However, subsequent notifications experience delays. After a while, all pending notifications arrive simultaneously, leading to a crash of the application.
packages:
firebase_core: ^2.30.0
firebase_messaging: ^14.8.2
Reproducing the issue
1-) Launch the application on an Android device.
2-) Send multiple push notifications to the device within a short period.
3-) Notice the delay in receiving subsequent notifications.
4-) After some time, observe all pending notifications being delivered simultaneously, leading to a crash of the application.
Firebase Core version
2.30.0
Flutter Version
3.19.6
Relevant Log Output
android.os.MessageQueue.nativePollOnce (Native method) android.os.MessageQueue.next (MessageQueue.java:335) android.os.Looper.loopOnce (Looper.java:161) android.os.Looper.loop (Looper.java:288) android.app.ActivityThread.main (ActivityThread.java:7872) java.lang.reflect.Method.invoke (Native method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:936)
Flutter dependencies
Expand
Flutter dependencies
snippetReplace this line with the contents of your `flutter pub deps -- --style=compact`.
Additional context and comments
No response
The text was updated successfully, but these errors were encountered: