繁体   English   中英

如何阻止Android上的Onesignal推送通知?

[英]How to block Onesignal push notifications on Android?

我知道我可以在Broadcast OnReceive()接收它们,但我无法阻止Onesignal创建Notification

您需要设置OneSignal NotificationExtenderService类并将其作为Service添加到AndroidManifest.xml中。

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

public class NotificationExtenderBareBonesExample extends NotificationExtenderService {
   @Override
   protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) {
        // Read properties from result.

      // Returning true tells the OneSignal SDK you have processed the notification and not to display it's own.
      return true;
   }
}

AndroidManifest.xml

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

有关详细信息,请参阅OneSignal Android 背景数据和通知覆盖文档。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM