包的开发人员警告 * 无法在频道“fcm_fallback_notification_channel”上发布通知更多详细信息请参阅日志

Posted

技术标签:

【中文标题】包的开发人员警告 * 无法在频道“fcm_fallback_notification_channel”上发布通知更多详细信息请参阅日志【英文标题】:Developer Warning for package * Failed to post notification on channel "fcm_fallback_notification_channel" See log for more details 【发布时间】:2021-04-14 08:46:00 【问题描述】:

我在尝试在 React Native 中实现推送通知时遇到此错误。

Developer Warning for package com.pn2
Failed to post notification on channel
"fcm_fallback_notification_channel"

See log for more details

我对此很陌生,我关注了这个视频http://youtube.com/watch?v=xSOr_u3Ev1s 并设法按照 Told 实现了所有内容,但我收到了警告并且推送通知没有显示。

我的代码是这样的:

index.js

/**
 * @format
 */

import AppRegistry, Platform from 'react-native';
import App from './App';
import name as appName from './app.json';
import PushNotification from 'react-native-push-notification';


PushNotification.configure(
  // (optional) Called when Token is generated (ios and android)
  onRegister: function (token) 
    console.log("TOKEN:", token);
  ,

  // (required) Called when a remote is received or opened, or local notification is opened
  onNotification: function (notification) 
    console.log("NOTIFICATION:", notification);

    // process the notification

    // (required) Called when a remote is received or opened, or local notification is opened
    notification.finish(PushNotificationIOS.FetchResult.NoData);
  ,

  // (optional) Called when Registered Action is pressed and invokeApp is false, if true onNotification will be called (Android)
  onAction: function (notification) 
    console.log("ACTION:", notification.action);
    console.log("NOTIFICATION:", notification);

    // process the action
  ,

  // (optional) Called when the user fails to register for remote notifications. Typically occurs when APNS is having issues, or the device is a simulator. (iOS)
  onRegistrationError: function(err) 
    console.error(err.message, err);
  ,

  // IOS ONLY (optional): default: all - Permissions to register.
  permissions: 
    alert: true,
    badge: true,
    sound: true,
  ,

  popInitialNotification: true,
  requestPermissions: Platform.OS ==="ios",
);

AppRegistry.registerComponent(appName, () => App);

App.js

import React from 'react';
import View, Text, StyleSheet , TouchableOpacity from 'react-native';
import showNotification from './src/notification';

const App = () =>
  return(
    <View style=styles.container>
      <Text>
        Push Notification 
      </Text>
      <TouchableOpacity onPress=() => showNotification('hello','test message') style=styles.Regbutton>
        <Text style=styles.loginbtn2> Show Notification! </Text>
         </TouchableOpacity>
    </View>
  )



export default App;


const styles = StyleSheet.create(
  container:
    flex: 1,
    justifyContent : 'center',
    alignItems: 'center'
  ,
      Regbutton:
        marginTop:16,
        width:300,
        height:52,
        padding:10,
        borderRadius:10,
        backgroundColor:'#ffffff',
        alignItems: 'center',
        borderWidth : 2,
        borderColor: '#030303'
    ,

    loginbtn2:
      color:'#030303',
      fontSize : 20,
      fontWeight : 'bold'
  ,
)

Notification.android.js

import PushNotification from 'react-native-push-notification';

const showNotification = (title, message) => 
    PushNotification.localNotification(
        title: title,
        message : message
    );
;

export showNotification;

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.pn2">

    <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                    android:value="false"/>
        <!-- Change the resource name to your App's accent color - or any other color you want -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                    android:resource="@color/white"/> <!-- or @android:color/name to use a standard color -->

        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
            </intent-filter>
        </receiver>

        <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
    </application>
</manifest>

build.gradle

  ext 
        googlePlayServicesVersion = "+" // default: "+"
        firebaseMessagingVersion = "+" // default: "+"
        buildToolsVersion = "29.0.3"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 25
        ndkVersion = "20.1.5948944"
        supportLibVersion = "23.1.1" // default: 23.1.1

是不是我做的不对?请协助。错误截图如下:

【问题讨论】:

【参考方案1】:

正如图片中的Moustafa Shamma 所示,缺少的部分是频道。 您需要创建一个频道才能在此处显示发送通知。

尝试将此添加到索引或应用程序:

 PushNotification.createChannel(
    channelId: "my-channel", // (required)
    channelName: "My channel", // (required)
 ,
 (created) => console.log(`CreateChannel returned '$created'`)
 );

然后在您的通知中添加频道 ID:

const showNotification = (title, message) => 
    PushNotification.localNotification(
        channelId: "my-channel",
        title: title,
        message : message
    );
;

【讨论】:

【参考方案2】:

检查这张图片 这将帮助你: https://imgur.com/S9QkJX0

【讨论】:

欢迎来到 Stack Overflow!请务必阅读How to Answer 和edit 你的答案。 从不,ever 提供代码图像而不是实际的可读文本块。此外,在发布一般链接或答案时,请提供额外的上下文和/或解释为什么这可以解决问题。使用编辑器中的 图标将您的代码块格式化为代码,请再次删除图像以在您的答案中使用文本。谢谢!

以上是关于包的开发人员警告 * 无法在频道“fcm_fallback_notification_channel”上发布通知更多详细信息请参阅日志的主要内容,如果未能解决你的问题,请参考以下文章

CMake:禁止开发人员警告

使用开发人员工具解决 Web 问题 - 警告按钮啥都不做?

如何找到此YouTube频道的用户ID /电子邮件

iPhone 开发者的 IRC 频道? [关闭]

为啥 iOS 会显示警告“此应用程序需要由开发人员更新才能在此版本的 iOS 上运行”。对于我的反应原生应用程序?

警告“开发人员工具访问需要控制另一个进程才能继续进行调试。输入您的密码以允许此操作。”