【发布时间】:2019-02-25 21:15:55
【问题描述】:
我很难使用 react-native-firebase 包向其他用户发送通知
环境详情:
- react-native 0.58.4
- react-native-firebase 5.2.2
- Android 8
我没有使用 firebase 身份验证 - 身份验证由 API 完成。
react-native-firebase 文档(Android 通知)中描述的所有设置都已严格遵守。
流程:
用户已成功通过身份验证。然后你的频道就定义好了。
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);
然后给自己发送如下通知。
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');
这可行,如下图所示。
当我与另一个用户(在另一个设备上)进行身份验证并尝试发送相同的通知时,就会出现问题。它没有到达第一台设备。
是否需要通过 firebase fcm 进行身份验证?
或将通知显示到另一台设备的其他设置?
提前致谢。
【问题讨论】:
标签: android firebase react-native firebase-cloud-messaging react-native-firebase