我知道我可以接收它们,Broadcast
OnReceive()
但我不能阻止 Onesignal 创建一个Notification
.
问问题
3826 次
1 回答
7
您需要设置一个 OneSignalNotificationExtenderService
类并将其添加到您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后台数据和通知覆盖文档。
于 2016-05-11T21:05:18.263 回答