I am trying to integrate the firebase message into my flutter application. On Android it works perfectly, but in Ios, when building the application, it opens a white screen and nothing else appears.
I was able to run the app successfully only once, where a request appeared to receive push messages from the firebase, even until I was able to send a notification.
I uninstalled the app and tried to install again, after that it only stays on a white screen and Ios no longer issues the notification requesting permission to send push.
In X-code Capabilities, I enabled Push Notifications and in Background modes "Background fetch" and "remote notifications"
Has anyone ever experienced this?
Verision: firebase_messaging: ^5.0.1+1
Main Dart
import 'package:App/injection/injector.dart';
import 'package:App/localization/MyLocalizationsDelegate.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter/material.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:App/pages/home/home.dart';
void main() => runApp(new NewsApp());
class NewsApp extends StatelessWidget {
MyLocalizationsDelegate myLocation = const MyLocalizationsDelegate();
FirebaseMessaging firebaseMessaging = new FirebaseMessaging();
String textToken = 'AQUI VAI O TOKEN';
NewsApp(){
Injector.configure(Flavor.PRO);
}
@override
void initState(){
print('iniciou o initState()');
firebaseMessaging.configure(
onLaunch: (Map<String, dynamic> msg){
print('chamou onLaunch');
},
onResume: (Map<String, dynamic> msg){
print('chamou onResume');
},
onMessage: (Map<String, dynamic> msg){
print('chamou onMessage');
}
);
firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(
sound: true,
alert: true,
badge: true
)
);
firebaseMessaging.onIosSettingsRegistered.listen((IosNotificationSettings setting) {
print('Configurações do IOS registradas');
});
firebaseMessaging.getToken().then((token){
update(token);
});
}
update(String token){
print(token);
textToken = token;
// setState((){
//
// });
}
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
initState();
return new MaterialApp(
debugShowCheckedModeBanner: false,
title: 'App',
theme: new ThemeData(
primarySwatch: Colors.blue,
primaryColor: Colors.blue,
accentColor: Colors.blue,
brightness: Brightness.light
),
supportedLocales: MyLocalizationsDelegate.supportedLocales(),
localizationsDelegates: [
myLocation,
DefaultCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
localeResolutionCallback: myLocation.resolution,
home: HomePage.create(),
);
}
}