android - PushSharp Google Cloud Messaging 单挑通知

标签 android push-notification notifications firebase-cloud-messaging heads-up-notifications

我正在为 Android 和 iOS 开发一个应用程序,我正在使用 PushSharp(在服务器端)向两个平台发送推送通知。特别是我正在使用(针对 Android)Firebase 平台 (FCM)。

正在关注 this指南 我能够将推送通知发送到 Android 设备设置图标和声音,但我认为存在问题。 当通知到达时,它不会显示为单挑通知,而只会显示为状态栏通知。

为了清楚起见,我会:

enter image description here

但我只看到状态栏上出现的应用程序图标。

我如何告诉 FCM 将我的通知显示为平视通知,类似于我使用以下代码获得的通知?

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
        })
}

关于android - PushSharp Google Cloud Messaging 单挑通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39044990/

相关文章:

java - 在最新的类路径中找不到ID为 'com.google.gms.google-services'的错误插件

java - 在android中以毫秒为单位获取系统时间

Android:如何像 YouTube 在他的应用程序中那样创建 WebView

android - Expo android应用程序,PushNotifications在独立apk中不起作用?

ios - 如何更新 Parse AppVersion

Android - 构建通知,TaskStackBuilder.addParentStack 不起作用

android - 在 android 中拍摄 SurfaceView 的屏幕截图

objective-c - didRegisterForRemoteNotificationsWithDeviceToken 未在 ios10 上调用

java - 奥利奥后通知背景颜色

error-handling - Nginx网关错误,如何通知