我有一个超级简单的推送通知接收器。我真的只是在AndroidManifest中设置了接收器:
<!-- Listener to receive Push Notifications -->
<service
android:name="com.example.pushnotifications.receiver.PushMessageReceiver"
android:exported="false"
tools:ignore="InnerclassSeparator">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
然后接收器类就是这样:
class PushMessageReceiver : GcmListenerService() {
override fun onMessageReceived(from: String?, data: Bundle?) {
super.onMessageReceived(from, data)
// empty. only receives and displays standard push notification
}
}
在非Oreo版本中,这会在操作系统的通知栏中发送推送通知徽章,播放默认通知声音,如果您点按通知徽章,则会打开该应用。
这就是我现在所需要的一切。这适用于非奥利奥版本,但奥利奥上没有任何内容。
知道为什么这不再适用了吗?
答案 0 :(得分:-3)
解决方案是将您的应用程序构建为较低版本的gradle,如2.3 改变所有项目的所有依赖项和geadle。 只需安装去年的android studio并在旧gradle上构建代码,确保在4.1到3.0.1或更早版本的gradle属性上更改gradle包。 它对我有用,直到新更新中的解决方案