When including a onBackgroundMessage listener to my flutter app, the callback is barely being known as when debugging not when the app is constructed for manufacturing.
Right here is the Firebase Perform in Node.js used to ship the data-only message:
async perform testFunc() {
await admin.messaging().ship({
information: {
query: "NEW",
theme: "blue",
kind: "widget-question",
snippetId: "2330hSHHjnsjkqnAn",
title: "New Snippet",
physique: "TESTNG",
theme: "blue",
snippetType: "regular",
index: "3"
},
apns: {
payload: {
aps: {
"content-available": 1
},
}
},
subject: "all"
})
}
Right here is the callback and initializer in flutter:
@pragma('vm:entry-point')
Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
print("Snippets: Dealing with a background message: ${message.messageId}");
// If you are going to use different Firebase companies within the background, similar to Firestore,
// ensure you name `initializeApp` earlier than utilizing different Firebase companies.
await Firebase.initializeApp(
choices: DefaultFirebaseOptions.currentPlatform,
);
await FBDatabase(uid: FirebaseAuth.occasion.currentUser!.uid).addBacklog({
"information": message.information,
});
}
void foremost() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
choices: DefaultFirebaseOptions.currentPlatform,
);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(const MainApp());
}
I’ve Background Fetch and Distant Notifications in my capabilities, and notifications are working positive.
I’ve tried altering the content-available to 1, however that did not work. All the things works positive in debug, however not manufacturing.