[英]How to send push notifications without OneSignal Dashboard?
[英]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.