停止在状态栏中显示OneSignal通知

时间:2016-06-30 08:54:00

标签: android push-notification onesignal

我已经实施了 OneSignal 并成功向我的Android应用发送通知,但我想根据推送通知中收到的其他数据丢弃一些通知。如何在状态栏中显示之前丢弃通知。

1 个答案:

答案 0 :(得分:4)

为此,请创建一个扩展NotificationExtenderService

的类

在此

import com.onesignal.OSNotificationPayload;
import com.onesignal.NotificationExtenderService;

public class NotificationExtenderBareBonesExample extends NotificationExtenderService {
   @Override
   protected boolean onNotificationProcessing(OSNotificationPayload notification) {
      // Read any properties you need from notification.
      // Return true if you want to keep a notification from displaying else return false if you dont want to display notification.
      return false;
   }
}

同样,当从面板发送通知时,请选中背景数据复选框

编辑清单文件以包含此内容: -

<service
   android:name=".YOUR_CLASS_NAME"
   android:exported="false">
   <intent-filter>
      <action android:name="com.onesignal.NotificationExtender" />
   </intent-filter>
</service>