I discovered that Firebase configuration and the service worker have limitations in in-app browsers. To address this, I wrapped the Firebase app initialization in a try-catch block.
let firebaseApp;
let messaging;
try {
firebaseApp = initializeApp(firebaseConfig);
messaging = getMessaging(firebaseApp);
} catch (err) {
console.error("Failed to initialize Firebase Messaging", err);
}