简体   繁体   English

推送通知发送到具有react-native-firebase的其他设备时的问题

[英]Problems When Push Notification Sending to Another Device With react-native-firebase

I'm having a hard time sending a notification to another user using the react-native-firebase package 我很难使用react-native-firebase软件包将通知发送给另一个用户

Environment Details: 环境详细信息:

  • react-native 0.58.4 反应本色0.58.4
  • react-native-firebase 5.2.2 react-native-firebase 5.2.2
  • Android 8 Android 8

I am not using firebase authentication - Authentication is done by an API. 我未使用Firebase身份验证-身份验证由API完成。

All the settings described by the react-native-firebase documentation (Android Notifications) have been strictly followed. 严格遵守react-native-firebase文档(Android Notifications)中描述的所有设置。

Flow: 流:

The user is successfully authenticated. 用户已成功认证。 Then your channel is defined. 然后定义您的频道。

fbase.messaging().hasPermission()
   .then(enabled => {
      if (!enabled) {
         fbase.messaging().requestPermission();
      }
   });

const channel = new fbase.notifications.Android.Channel(userId, 'User Notifications', fbase.notifications.Android.Importance.Max)
   .setDescription('Logged in users notifications');
//userId is 43
fbase.notifications().android.createChannel(channel);

Then a notification is sent to himself as follows. 然后,将通知发送给自己如下。

const notification = new fbase.notifications.Notification()
  .setNotificationId('6878')
  .setTitle(`Proposta respondida por Zé Carlos`)
  .setBody('Sim, estamos à disposição. Chame-nos no chat qualquer coisa.')
  .setData({
    action: 'Proposta Respondida',
    serviceOrderId: '68',
    companyAvatar: null,
    companyName: 'Auto Mecânica Joãozinho'
  });
  notification.android.setChannelId('43');
  notification.android.setSmallIcon("ic_notification");
  notification.android.setVibrate([1000, 1000]);
  notification.android.setLargeIcon('imageUrl');
  notification.android.setTicker('Não falou nada não falou em');

This works, as shown in the following image. 如下图所示,此方法有效。

Notification Image 通知图片

The problem happens when I authenticate with another user (on another device) and try to send that same notification. 当我与另一个用户(在另一个设备上)进行身份验证并尝试发送相同的通知时,就会发生问题。 It does not arrive on the first device. 它不会到达第一台设备上。

It would be required to authenticate through the firebase fcm? 是否需要通过Firebase fcm进行身份验证?

Or other settings for display the notification to another device? 或用于将通知显示到另一台设备的其他设置?

Thank You in Advance. 先感谢您。

The way you choosed, you only able to send local notifications. 您选择的方式只能发送本地通知。

For example this is used, if you receive an data-only messages from FCM , which is not displayed by your app automatically... you have to handle this. 例如,如果您从FCM接收到仅数据消息 ,而该消息不会由您的应用自动显示,则使用此消息 ...您必须处理此问题。 (Described here ) 在这里描述)

To send Notification to other devices, you have to use firebase.messaging.RemoteMessage() 要将Notification发送到其他设备,您必须使用firebase.messaging.RemoteMessage()

Have a look here: https://rnfirebase.io/docs/v5.xx/messaging/upstream-messages 在这里看看: https : //rnfirebase.io/docs/v5.xx/messaging/upstream-messages

Hope, thats helps you a bit. 希望,这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当应用程序运行时,react-native-firebase收到通知 - react-native-firebase receiving notification when app in running React-native-firebase 后台通知(Android) - React-native-firebase notification in background (Android) react-native-firebase 通知崩溃 - react-native-firebase notification crash react-native-firebase-收到推送通知后应用崩溃(Android) - react-native-firebase - App Crash after Push Notification Received (Android) 使用 react-native-firebase v6,应用程序在前台收到通知时崩溃 - With react-native-firebase v6, app crashed when receive notification while in foreground 默认情况下如何使用react-native-firebase启用浮动通知? - How to enabled floating notification by default with react-native-firebase? 反应原生Firebase推送通知Android - React native Firebase push notification Android 使用“react-native-firebase v6”将数据从通知传递到它打开的应用程序的最佳方法是什么? - What is the best approach to passing data from a notification to the application that it opens, using “react-native-firebase v6”? 任务 :react-native-firebase:compileReleaseJavaWithJavac 失败 - Task :react-native-firebase:compileReleaseJavaWithJavac FAILED 使用 react-native-firebase 启用 Proguard - Enable Proguard with react-native-firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM