OneSignal / OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Other
604 stars 368 forks source link

[Bug]: The INotificationClickListener does not work on HMS devices after the migration to OneSignal SDK v5.1.5 #2020

Open gabrielvrebac opened 8 months ago

gabrielvrebac commented 8 months ago

What happened?

After migrating from OneSignal SDK v4.8.6 to v5.1.5, the OneSignal.Notifications.addClickListener no longer works on Huawei (HMS) devices when clicking on a push notification.

I also checked out the OneSignal example code and overwrote the following to send a push via our OneSignal project:

The push notification arrives on GMS and HMS. However, the INotificationClickListener only works on GMS but not on HMS. The implementation of "INotificationServiceExtension" (here) does not work with HMS either.

Steps to reproduce?

1. Checkout the [OneSignal example project](https://github.com/OneSignal/OneSignal-Android-SDK/tree/main/Examples/OneSignalDemo)
2. Upgrade the Gradle plugin to v8.2.2 in Android Studio via `Tools > AGP Upgrade Assistant ...`
3. Update the agconnect classpath (`com.huawei.agconnect:agcp`) in the "build.gralde" from `1.6.2.300` to `1.9.1.303`
4. Update the Huawei push dependency (`com.huawei.hms:push`) in the "app/build.gradle" from `6.3.0.304` to `6.12.0.300`
5. Install the Huawei variant on an HMS device
6. Send a push and click on the push notification

What did you expect to happen?

After clicking on the push notification on a HMS device, the INotificationClickListener, which is set in the MainApplication (here), should be triggered and the log should contain the following output "INotificationClickListener.onClick fired with event: com.onesignal.notifications.internal.NotificationClickEvent@3e09b8f"

OneSignal Android SDK version

Release 5.1.5

Android version

12

Specific Android models

HUAWEI P40 lite

Relevant log output

############################## GMS ##############################
2024-02-27 18:11:32.353 27112-27112 sdktest                 D  OneSignal SDK initialized
2024-02-27 18:11:32.721 27112-27157 sdktest                 V  IRemoteNotificationReceivedHandler fired with INotificationReceivedEvent: com.onesignal.notifications.internal.NotificationReceivedEvent@ccb3334
2024-02-27 18:11:38.709 27112-27112 sdktest                 D  Privacy consent required set: true
2024-02-27 18:11:38.747 27112-27112 sdktest                 V  INotificationClickListener.onClick fired with event: com.onesignal.notifications.internal.NotificationClickEvent@3e09b8f

############################## HMS ##############################
2024-02-27 18:15:26.823 17117-17117 sdktest                 D  OneSignal SDK initialized
2024-02-27 18:15:26.931 17117-17117 sdktest                 D  Privacy consent required set: true

Code of Conduct

jkasten2 commented 8 months ago

@gabrielvrebac Thanks for reporting!

We were able to reproduce a problem with HMS push not firing INotificationClickListener as well.

On your 2nd question, the INotificationServiceExtension only works for HMS pushes if you use huawei_msg_type as "data". OneSignal set this to "message" by default as the reliability is lower for the "data" message type, due to limitations of HMS Core on the device.