我正在尝试将firebase消息集成到我的flutter应用程序中。在Android上,它可以完美运行,但是在Ios中,构建应用程序时,它会打开白屏,并且没有其他显示。
我只能成功运行一次该应用程序,其中出现了从Firebase接收推送消息的请求,甚至直到我能够发送通知为止。
我卸载了该应用程序并尝试再次安装,之后它仅停留在白屏上,并且Ios不再发出通知,请求发送推送的权限。
在X代码功能中,我启用了推送通知,并在后台模式下启用了“背景提取”和“远程通知”
有人经历过吗?
版本:firebase_messaging:^ 5.0.1 + 1
主飞镖
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(),
);
}
}
答案 0 :(得分:0)
尝试降级您的firebase_messaging插件以及firebase_core