云消息传递firebase(推送通知)问题

时间:2019-02-04 23:49:24

标签: push-notification flutter firebase-cloud-messaging android-notifications flutter-dependencies

我的设置:

  • 我迁移到了android X
  

版本:1.0.0 + 1环境:sdk:“> = 2.0.0-dev.68.0 <3.0.0”

     

依赖项:firebase_messaging:^ 3.0.0

我的代码

import 'package:firebase_messaging/firebase_messaging.dart';

//...

class App extends StatefulWidget {
  @override
  _AppState createState() => _AppState();
}

class _AppState extends State<App> {
  final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();

  @override
  void initState() {
    super.initState();
//    _firebaseMessaging.configure(
//      onMessage: (Map<String, dynamic> message) {
//        print('on message $message');
//      },
//      onResume: (Map<String, dynamic> message) {
//        print('on resume $message');
//      },
//      onLaunch: (Map<String, dynamic> message) {
//        print('on launch $message');
//      },
//    );
    _firebaseMessaging
        .requestNotificationPermissions(const IosNotificationSettings(
      sound: true,
      badge: true,
      alert: true,
    ));
    _firebaseMessaging.getToken().then((token) {
      print('token ' + token);
    });
  }
//...
}

当我从Firebase控制台发送测试通知时,这是我在控制台中获得的信息,而在我的真实设备中什么也没有,甚至onMessage也没有被调用(我在另一个设备,我没有收到任何通知,但是叫onMessage

D/ActivityThread( 7252): BDC-Calling onReceive: intent=Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000010 pkg=com.example.firstapp cmp=com.example.firstapp/com.google.firebase.iid.FirebaseInstanceIdReceiver (has extras) }, receiver=com.google.firebase.iid.FirebaseInstanceIdReceiver@c155cc5
V/ActivityThread( 7252): SVC-Creating service CreateServiceData{token=android.os.BinderProxy@cbab61a className=io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService packageName=com.example.firstapp intent=null}
D/ActivityThread( 7252): SVC-Calling onStartCommand: io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService@117a54b, flags=0, startId=1
V/ActivityThread( 7252): SVC-Destroying service io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService@117a54b
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteDatabase( 7252): beginTransaction()
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteDatabase( 7252): endTransaction()
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteDatabase( 7252): beginTransaction()
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteDatabase( 7252): endTransaction()
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteDatabase( 7252): beginTransaction()
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteDatabase( 7252): endTransaction()
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteDatabase( 7252): beginTransaction()
D/SQLiteConnectionPool( 7252): really get connection
D/SQLiteDatabase( 7252): endTransaction()

0 个答案:

没有答案