我有一个超级简单的推送通知接收器。我真的只是在 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
}
}
在非奥利奥版本中,这会在操作系统的通知栏中发送一个推送通知徽章,播放默认通知声音,如果您点击通知徽章,应用程序就会打开。
这就是我现在真正需要的。这适用于非奥利奥版本,但奥利奥上没有任何显示。
知道为什么这不再起作用了吗?