Firebase云消息传递使我的应用程序崩溃

时间:2020-06-04 14:00:18

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

大约一个星期以来,我一直在使用Firebase云消息传递遇到很多问题。我只想要Firebase云消息传递的最简单功能。我只想通知我的应用程序用户。我已经反复尝试了3天。它开始工作。它只工作了一次。通知已发送到我的移动设备。但是在任何时候都将通知发送到任何设备。它不断崩溃的应用程序。该应用程序说它一直停下来。这样的事情。我已经放入了所有适当的SDK。并且已经重启了很多次。请帮助我,任何人都可以。

这是我的Andriod清单文件(至少我可以显示的部分)

  <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <service
           android:name=".java.MyFirebaseMessagingService"
           android:exported="false">
          <intent-filter>
              <action android:name="com.google.firebase.MESSAGING_EVENT" />
          </intent-filter>
        </service>

这是我的应用程序build.gradle(也是与Firebase消息传递相关的部分)

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-messaging:20.2.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.android.gms:play-services-ads:19.1.0'
}

和我的pubspec.yaml

name: boomm
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_spinkit: ^4.1.2
  intl: ^0.16.1
  font_awesome_flutter: ^8.8.1
  curved_navigation_bar: ^0.3.2  
  firebase_auth: ^0.14.0+5
  cloud_firestore: ^0.13.6
  flutter_screenutil: ^0.4.2
  flutter_staggered_grid_view: "^0.3.0"
  firebase_storage: ^3.1.5
  photo_manager: ^0.5.1
  timeago: ^2.0.26
  geolocator: 5.0.1
  uuid: ^2.0.0
  provider: ^4.1.2
  image: ^2.0.7
  path_provider: ^0.5.0+1
  admob_flutter: "^0.3.4"
  firebase_messaging: ^6.0.16
  cached_network_image: 
  flutter_svg:


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/images/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: Comic
      fonts:
        - asset: assets/fonts/ComicNeue-Regular.ttf
    - family: Lobster
      fonts:
        - asset: assets/fonts/Lobster-Regular.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

0 个答案:

没有答案