我知道我可以在
Broadcast
的OnReceive()
方法中接收它们,但我无法阻止OneSignal创建一个Notification
。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>
<meta-data android:name="com.onesignal.NotificationServiceExtension"
android:value=".notifications.RemoteNotificationReceivedHandler" />