我正在尝试读取我的通知的有效内容,但事件不会触发。对于数据消息来说,它可以正常工作,但好像没有注意到通知。
AndroidManifest:
<service
android:name="com.huawei.hms.push.react.RNHmsMessageService"
android:exported="true">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver android:name="com.huawei.hms.push.react.RNReceiver"/>
<meta-data
android:name="push_kit_auto_init_enabled"
android:value="true" />
RNHmsMessageService
public void onMessageReceived(RemoteMessage message) {
Log.i(TAG, "onMessageReceived is called");
if (message == null) {
Log.e(TAG, "Received message entity is null!");
return;
}
Log.i(TAG, "getCollapseKey: " + message.getCollapseKey()...
RemoteMessage.Notification notification = message.getNotification();
if (notification != null) {
Log.i(TAG, "\n getImageUrl: " + notification.getImageUrl()...
}
Boolean judgeWhetherIn10s = false;
// If the messages are not processed in 10 seconds, the app needs to use WorkManager for processing.
if (judgeWhetherIn10s) {
startWorkManagerJob(message);
} else {
// Process message within 10s
processWithin10s(message);
}
}
build.gradle
implementation 'com.huawei.hms:push:4.0.4.301'
我认为message.getNotification()始终为空,因此不会触发。
"foreground_show": false
,仍无法使其正常工作,通知总是出现在状态栏中。 - deviant