代码之家  ›  专栏  ›  技术社区  ›  Eugenio Valeiras

React Native FireBase-收到推送通知后应用程序崩溃(Android)

  •  0
  • Eugenio Valeiras  · 技术社区  · 7 年前

    我有一个 NoDEJS服务器 当我 响应本地应用程序 从服务器接收推送通知,应用程序停止工作。

    仿真器 应用程序刚关闭,手机中有一个发布的apk被安装,应用程序关闭,并显示一个警告说应用程序停止工作。

    在这里,我可以展示我在Android应用程序中添加的一些配置。

    安卓/build.gradle

    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath 'com.google.gms:google-services:4.0.1'
    

    平地

    implementation project(':react-native-firebase')
    implementation 'com.google.android.gms:play-services-base:15.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    

    通知侦听器

    export const configureMessaging = async () => {
      try {
        const enabled = await FirebaseMessaging.hasPermission();
        log('Push Notifications enabled?', enabled);
        return enabled;
      } catch (err) {
        return false;
      }
    }; // This is returning true
    
    export const configureOnNotificationDisplayed = () => FirebaseNotifications.onNotificationDisplayed((notification) => {
      // Process your notification as required
      // ANDROID: Remote notifications do not contain the channel ID.
      // You will have to specify this manually if you'd like to re-display the notification.
      console.log(notification);
    });
    
    export const configureOnNotification = () => FirebaseNotifications.onNotification((notification) => {
      // Process your notification as required
      console.log(notification);
    });
    
    export const configureOnNotificationOpened = () => FirebaseNotifications.onNotificationOpened((notificationOpen) => {
      // Get the action triggered by the notification being opened
      // Get information about the notification that was opened
      console.log(notification);
    });
    

    我在AVM中附加了一个调试器,没有抛出任何错误。

    连接到目标VM,地址:“localhost:8624”,传输: “套接字”

    与目标虚拟机断开,地址:'localhost:8624', transport:'插座'

    注释

    我不知道iOS中发生了什么,因为应用程序没有配置 使用iOS

    1 回复  |  直到 7 年前
        1
  •  0
  •   Eugenio Valeiras    7 年前

    问题是我有另一个使用推送通知的依赖项。我把它拿走了,一切都很好