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

时间:2016-05-11 08:09:50

标签: android onesignal

我知道我可以在Broadcast OnReceive()收到这些内容,但我无法阻止Onesignal创建Notification

1 个答案:

答案 0 :(得分:7)

您需要设置OneSignal NotificationExtenderService课程,并将其作为AndroidManifest.xml添加到Service

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 Background Data and Notification Overriding文档。