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