我正在为android和ios开发一个应用程序,并使用pushsharp(服务器端)向两个平台发送推送通知。特别是我正在使用(Android)的FireBase平台(FCM)。
根据this指南,我可以发送推送通知到android设备设置图标和声音,但我认为有一个问题。
当通知到达时,它不会显示为head-up通知,而只显示为状态栏通知。
明确地说,我会:
但我只看到状态栏上出现的应用程序图标。
如何告诉fcm将我的通知显示为head-up通知,类似于使用以下代码获得的通知?
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_media_play)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_HIGH);
最佳答案
我已经安装了以下版本的react-native-push-notification
npm install zo0r/react-native-push-notification.git
在你的
index.android.js
function init(){
PushNotification.configure({
onNotification:async (notification)=>{
if(!notification.userInteraction && !notification.foreground){
PushNotification.localNotification({
message: "you message"
});
}
,
requestPermissions:true,
senderID:"31************",
popInitialNotification:false
})
}