OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.56k stars 371 forks source link

event received is not working with Huawei devices (not supported from google) #1096

Closed bishoymakkar closed 3 years ago

bishoymakkar commented 3 years ago

I go on the same steps on documentation to use HMS push with one signal https://documentation.onesignal.com/docs/huawei-sdk-setup

after using one signal with hms push as documentation , I can't use recieved event for one signal it's not working also opened event is working

React-Native: 0.61.5 react-native-onesignal : 3.9.1

minSdkVersion = 19 compileSdkVersion = 29 targetSdkVersion = 29

I used constructor (props) { OneSignal.addEventListener('received', this.onReceived); }

in app.js working with all platforms except Huawei devices whose not supported from google

also i tried to create service class like native projects

rgomezp commented 3 years ago

Howdy, Can you please include a log by setting the OneSignal logLevel to VERBOSE?

Cheers

rgomezp commented 3 years ago

Closing due to no response.

mstankov commented 3 years ago

@rgomezp thought I might bump this one instead of making a new issue. I'm experiencing the same thing - successfully integrated HMS in an existing react-native app. I can confirm that is OneSignal is properly initialized - all provided handlers are set. The remote notification is indeed received and the user can see it in the status bar. Clicking on the notification behaves as expected - either brings back the activity or starts a new one, onNotificationOpened is called and triggered on the javascript side.

The application seems to be ignoring OneSignal's notification received event handlers though. I've tested the exact same logic, following the same steps, on a regular android app (both tests performed on physical devices, both using Android 10) and all handlers are called appropriately.

Used libraries:

react-native-onesignal": "^4.0.3"
gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.9, 0.99.99]
com.onesignal:OneSignal:[4.0.0, 4.99.99]
com.huawei.agconnect:agcp:1.4.2.301
com.huawei.agconnect:agconnect-core:1.4.2.301
com.huawei.hms:push:5.0.0.300

Here's an example log for a received remote notification:

2021-01-18 01:12:39.177 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]com.my.application.id  in user 0 ,uid is 10184
2021-01-18 01:12:39.180 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]com.my.application.id  in user 0 ,uid is 10184
2021-01-18 01:12:39.192 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]send selfshow msg to NC to display, pkgName:com.my.application.id,msgID:02046E64C48FE118,haStorageId:-1,userId:0,subjectId:
2021-01-18 01:12:39.206 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]handleMessageResponse the response msg is :45,msgId:02046E64C48FE118,displayPkgName:com.my.application.id,flag:00
2021-01-18 01:12:39.228 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]com.my.application.id is not registed,user id is 0
2021-01-18 01:12:39.230 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]handleMessageResponse the response msg is :45,msgId:02046E64C48FE119,displayPkgName:com.my.application.id,flag:13
2021-01-18 01:12:39.236 23648-28419/? I/PushLogNC110006309: [ReceiverHandler-pool-thread-6-6267]getNotificationChannel pkgName: com.my.application.id channelId: OS_151e8ab2-c2c8-48be-b091-d8dc498fd7c7(pushagent/:61)
2021-01-18 01:12:39.238 23648-28419/? I/PushLogNC110006309: [ReceiverHandler-pool-thread-6-6267]getNotificationChannel pkgName: com.my.application.id channelId: com.huawei.android.pushagent50478(pushagent/:61)
2021-01-18 01:12:39.248 23648-28419/? I/PushLogNC110006309: [ReceiverHandler-pool-thread-6-6267]createChannelForTargetPackage success, target pkg is com.my.application.id(pushagent/:281)
2021-01-18 01:12:39.251 1400-2473/? V/HwNotificationService: Notification Center targetPkg:com.my.application.id
2021-01-18 01:12:39.252 1400-2473/? I/NotificationService: enqueueNotificationInternal: pkg=com.my.application.id id=1022077870 notification=Notification(channel=com.huawei.android.pushagent50478 pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x110 color=0x00000000 vis=PRIVATE)
2021-01-18 01:12:39.253 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]com.my.application.id is not registed,user id is 0
2021-01-18 01:12:39.254 1400-2473/? I/NotificationService: enqueueNotificationInternal Channel Info : pkg=com.my.application.id id=1022077870 importance =3
2021-01-18 01:12:39.255 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]handleMessageResponse the response msg is :45,msgId:02046E64C48FE11C,displayPkgName:com.my.application.id,flag:13
2021-01-18 01:12:39.256 23648-28419/? I/PushLogNC110006309: [ReceiverHandler-pool-thread-6-6267]BadgeClassName: PackageName:com.huawei.android.pushagent DispPkgName:com.my.application.id BadgeAddNum:1 BadgeSetNum:-1(pushagent/:202)
2021-01-18 01:12:39.276 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]com.my.application.id is not registed,user id is 0
2021-01-18 01:12:39.278 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]handleMessageResponse the response msg is :45,msgId:02046E64C48FE11D,displayPkgName:com.my.application.id,flag:13
2021-01-18 01:12:39.297 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]com.my.application.id is not registed,user id is 0
2021-01-18 01:12:39.299 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]handleMessageResponse the response msg is :45,msgId:02046E64C48FE11A,displayPkgName:com.my.application.id,flag:13
2021-01-18 01:12:39.319 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]com.my.application.id is not registed,user id is 0
2021-01-18 01:12:39.321 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]handleMessageResponse the response msg is :45,msgId:02046E64C48FE11B,displayPkgName:com.my.application.id,flag:13
2021-01-18 01:12:39.339 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]com.my.application.id is not registed,user id is 0
2021-01-18 01:12:39.341 4254-4289/? I/PushLog110006309: [ReceiverDispatcher-240]handleMessageResponse the response msg is :45,msgId:02046E64C48FE11E,displayPkgName:com.my.application.id,flag:13
2021-01-18 01:12:39.359 1400-1400/? V/HwNotificationService: isHwSoundAllow pkg=com.my.application.id, channelId=com.huawei.android.pushagent50478, userId=0, cfg=3
2021-01-18 01:12:39.360 1400-1400/? V/HwNotificationService: isHwVibrateAllow pkg=com.my.application.id, channelId=com.huawei.android.pushagent50478, userId=0, cfg=3
2021-01-18 01:12:39.360 1400-1400/? I/NotificationService: buzzBeepBlinkLocked hasValidSound=true,hasValidVibrate=true,key=0|com.my.application.id|1022077870|null|10184
2021-01-18 01:12:39.373 2374-2442/? I/AppManager: app:com.my.application.id Notification update time:521749098
2021-01-18 01:12:39.374 2145-2145/? I/NotificationListener: onNotificationPosted: StatusBarNotification(pkg=com.my.application.id user=UserHandle{0} id=1022077870 tag=null key=0|com.my.application.id|1022077870|null|10184: Notification(channel=com.huawei.android.pushagent50478 pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x110 color=0x00000000 vis=PRIVATE)) important=3, post=1610925159254, when=1610925159230,showWhen=true, vis=0, userid=0, hasFullScreenIntent=false
2021-01-18 01:12:39.455 2145-2145/? I/ScrollLayout2: addContainerView StatusBarNotification(pkg=com.my.application.id user=UserHandle{0} id=1022077870 tag=null key=0|com.my.application.id|1022077870|null|10184: Notification(channel=com.huawei.android.pushagent50478 pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x110 color=0x00000000 vis=PRIVATE))
2021-01-18 01:13:17.189 1400-1400/? I/JobServiceContext: Client timed out while executing (no jobFinished received), sending onStop: f3cd651 #u0a184/2081862118 com.my.application.id/com.onesignal.FocusDelaySyncJobService
2021-01-18 01:13:17.195 27379-27379/com.my.application.id D/OneSignal: FocusDelaySyncJobService onStopJob called, system conditions not available reschedule: false

Any help is appreciated, thanks

sktan810 commented 3 years ago

@rgomezp I encounter same issue as @bishoymakkar , cannot receive any event from OneSignal, as also unable to display notification in status bar.

Used libraries react-native-onesignal": "^3.9.3" gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99] com.onesignal:OneSignal:3.15.6 com.huawei.agconnect:agcp:1.4.2.301 com.huawei.agconnect:agconnect-core:1.4.2.301 com.huawei.hms:push:5.0.0.300

rgomezp commented 3 years ago

Thank you for your patience.

The application seems to be ignoring OneSignal's notification received event handlers though.

Please note that in version 4, the notification received event handlers changed. Please take a look at our documentation to ensure you're using our latest API.

docs

migration docs

rgomezp commented 3 years ago

Closing due to no response