Skip to content
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] PlatformException(channel-error) on iOS Simulator 17.5 with Firebase 3.12.0 #17138

Open
1 task done
imblubb opened this issue Feb 24, 2025 · 4 comments
Open
1 task done
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. platform: ios Issues / PRs which are specifically for iOS. plugin: core type: bug Something isn't working

Comments

@imblubb
Copy link

imblubb commented Feb 24, 2025

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Core, Messaging

Which platforms are affected?

iOS

Description

Firebase.initializeApp fails with PlatformException(channel-error, Unable to establish connection on channel., null, null) on iOS 17.5 simulator (Xcode 15.4). The app runs fine without Firebase, showing "STAlert" and "Waiting for PLC Alert…". This persists across simulator versions (17.5 and 17.4) and Firebase SDK versions (11.8.0 with 3.12.0/15.2.3, 10.25.0 with 2.24.2/14.7.10). Suspect a simulator-specific issue with the Firebase iOS SDK, as all configs (.p8 key, GoogleService-Info.plist, entitlements) are correct and Xcode builds cleanly. No physical device available for testing.

Reproducing the issue

  1. Create a Flutter app with firebase_core: ^3.12.0 and firebase_messaging: ^15.2.3.

  2. Configure Firebase for iOS:

    • Add GoogleService-Info.plist to Runner > "Copy Bundle Resources".
    • Enable Push Notifications in Xcode + add Runner.entitlements with aps-environment: development.
    • Upload .p8 key (sandbox + production) to Firebase Console > Cloud Messaging > Apple app configuration.
  3. Update main.dart:

    import 'package:firebase_core/firebase_core.dart';
    import 'package:firebase_messaging/firebase_messaging.dart';
    import 'package:flutter/material.dart';
    import 'firebase_options.dart';
    
    Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
      print("Background message: ${message.notification?.title}");
    }
    
    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      try {
        await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
        FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
        await FirebaseMessaging.instance.requestPermission();
        String? token = await FirebaseMessaging.instance.getToken();
        print("FCM Token: $token");
      } catch (e) {
        print("Firebase init failed: $e");
      }
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(title: Text('STAlert')),
            body: Center(child: Text('Waiting for PLC Alert...')),
          ),
        );
      }
    }
    
  4. Run ios 17.5 simulator
    flutter run -d "iPhone 15 Pro Max"

  5. Observe: PlatformException(channel-error, Unable to establish connection on channel., null, null) in logs.

Firebase Core version

3.12.0 (also tested 2.24.2)

Flutter Version

3.29.0 (stable)

Relevant Log Output

[ +297 ms] flutter: Starting app...
flutter: Attempting Firebase initialization...
flutter: Options: {apiKey: REDACT, appId: REDACT, messagingSenderId: REDACT, projectId: stalert, authDomain: null, databaseURL: null, storageBucket: stalert.firebasestorage.app, measurementId: null, trackingId: null, deepLinkURLScheme: null, androidClientId: null, iosClientId: null, iosBundleId: com.example.stalertApp, appGroupId: null}
[   +5 ms] flutter: Firebase initialization failed: PlatformException(channel-error, Unable to establish connection on channel., null, null)
flutter: Stacktrace: #0      main (package:stalert_app/main.dart:24:37)
<asynchronous suspension>
flutter: Continuing without Firebase...
flutter: Running app UI...

Flutter dependencies

dependencies:
flutter:
sdk: flutter
firebase_core: ^3.12.0
firebase_messaging: ^15.2.3

Full run_log.txt and flutter doctor -v available on request.

Additional context and comments

  • Xcode builds cleanly (no errors post-Pod fixes).
  • Tried simulator reset (deleted/re-added), iOS 17.5 and 17.4—same error.
  • .p8 key updated to sandbox + production, uploaded to Firebase.
  • Push Notifications enabled with Runner.entitlements (aps-environment: development).
  • Xcode console: "FIRMessaging proxy enabled" but no specific native error.
  • Originally posted as discussion: PlatformException(channel-error) on iOS Simulator 17.5 with Firebase 3.12.0 #17137
  • No physical device available—need simulator workaround.
@imblubb imblubb added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Feb 24, 2025
@SelaseKay SelaseKay added plugin: core platform: ios Issues / PRs which are specifically for iOS. labels Feb 25, 2025
@SelaseKay
Copy link
Contributor

Hi @imblubb, I couldn't reproduce this issue. Could you share a minimal repository that I can clone to investigate further?

@SelaseKay SelaseKay added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Feb 25, 2025
@imblubb
Copy link
Author

imblubb commented Feb 25, 2025

Hi @imblubb, I couldn't reproduce this issue. Could you share a minimal repository that I can clone to investigate further?

Thank you for your response. I greatly appreciate it.

Here’s the minimal repo:

  • Repo: https://github.com/imblubb/firebase-simulator-error

  • Steps: Clone, flutter pub get, flutter run -d "iPhone 15 Pro Max"

  • Result: With my real config (local), I get PlatformException(channel-error, ...). Redacted config in repo (dummy values) may crash differently, but error matches my setup:

    [ +303 ms] flutter: Starting app...
    flutter: Attempting Firebase initialization...
    flutter: Options: {apiKey: AIzaSyAnAm1rFSEslue-ldsWNQa3cPGPVfDAeRc, appId: 1:693780686853:ios:c84113c1ea3f213eedd46c, ..., iosBundleId: com.example.stalertApp, ...}
    [ +5 ms] flutter: Firebase initialization failed: PlatformException(channel-error, Unable to establish connection on channel., null, null)
    flutter: Running app UI...

UI loads ("Firebase Simulator Error" + "Testing Firebase"). Logs removed for privacy—can share privately if needed

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Feb 25, 2025
@SelaseKay
Copy link
Contributor

Hi @imblubb, I'm not able to reproduce your error. When I run your sample, the app crashed. The crash was related to invalid an apiKey.

@SelaseKay SelaseKay added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Feb 26, 2025
@MichaelVerdon
Copy link
Contributor

Hey there, I would suggest updating your firebase dependencies as there are newer versions available (3.12.1 and 15.2.4 respectively) , please tell me how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. platform: ios Issues / PRs which are specifically for iOS. plugin: core type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants