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

ANR error after receiving the first push notification when combine FCM for android and Push for IOS #50

Open
javier-gantri opened this issue Feb 12, 2024 · 1 comment

Comments

@javier-gantri
Copy link

javier-gantri commented Feb 12, 2024

Steps:
1 - create an empty flutter project (3.16.9)
2 - flutter pub add firebase_core firebase_messaging push
3 - configure android build.gradle
4 - add basic subscription for push message
5 - run android project
6 - sent a push notification using firebase cloud


import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;

  @override
  void initState() {
    super.initState();

    _firebaseMessaging.requestPermission();

    FirebaseMessaging.instance.getInitialMessage();

    FirebaseMessaging.onMessage.listen((RemoteMessage message) {
      print(message);
      print('OnMessage');
    });

    FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
      print(message);
      print('OnMessageOpened');
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Container(),
    );
  }
}

CleanShot 2024-02-11 at 22 02 08@2x

@javier-gantri javier-gantri changed the title ANR error after received the first push notification when combine FCM for android and Push for IOS ANR error after receiving the first push notification when combine FCM for android and Push for IOS Feb 12, 2024
@ben-xD
Copy link
Owner

ben-xD commented May 1, 2024

Hey @javier-gantri, why do you need both firebase_messaging and push installed at the same time? This is something I haven't tested but, but if it makes sense I could try make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants