react-native-push-notification前台通知

时间:2018-12-21 10:37:22

标签: react-native

我正在通过本机开发一个应用程序。
我需要发送带有推送通知的数据,但是在android中,当我收到通知时,它会在屏幕上显示。
我配置了如下通知:

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.0/angular.min.js"> 
</script>
@Component({
  selector: 'app-dashboard2',
  templateUrl: './dashboard2.component.html',
  styleUrls: ['./dashboard2.component.scss']
})
export class Dashboard2Component implements OnInit {

  numberofSupport: number=0;
  supportButtonclick(){
    this.numberofSupport++;

  }
  unsupportButtonclick(){
    this.numberofSupport--;
  }

 

有什么办法可以禁用此选项?

2 个答案:

答案 0 :(得分:0)

我找到了解决方案 在react-native-push-notification文件夹下的node_modules文件夹中:

  

java / com / dieam / reactnativepushnotification / modules / RNPushNotificationListenerService.java

我更改了此内容:

pushNotificationHelper.sendToNotificationCentre(bundle);

对此:

if (!isForeground) {
pushNotificationHelper.sendToNotificationCentre(bundle);
}

答案 1 :(得分:0)

已根据6.1.3版本更新 将此添加到AndroidManifest.xml的application中。 https://github.com/zo0r/react-native-push-notification/blob/master/example/android/app/src/main/AndroidManifest.xml

  <service
      android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
      android:exported="false" >
      <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
  </service>

  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
              android:value="false"/>
  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
              android:resource="@android:color/white"/>
</application>
相关问题