Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cordova-plugin-hms-push onNotificationOpenedApp call without result data #139

Open
victor-sanchez-ccc opened this issue Aug 4, 2023 · 0 comments

Comments

@victor-sanchez-ccc
Copy link

victor-sanchez-ccc commented Aug 4, 2023

Description
I trying to capture push notification content, but the onNotificationOpenedApp is triggering when i tap on a push and my app oppen but the result data comes in empty object. the plugin works correctly for receive push notification, but not works for get the push info data or text to my app.

Expected behavior
result data comes with push info to be capture inside my app, when onNotificationOpenedApp event is fire, as show in documentation

onNotificationOpenedApp(callback)

Current behavior
result comes in empty object when app opened by touching a push notification

Logs

Logs from log inspector android studio running my app

I/HMSSDK_PendingResultImpl: init uri:push.gettoken
I/HmsPushInstanceId: HMSPush plugin initialized
I/HMSSDK_PendingResultImpl: setResultCallback
I/HMSSDK_HmsMessaging: invoke turnOnPush
I/HMSSDK_HMSPackageManager: Enter getHMSPackageNameForMultiService
I/chromium: [INFO:CONSOLE(15)] "NOTIFICATION_OPENED_EVENT {}", source: https://localhost/dist/bundle.js (15) <-- console log from app js
I/HMSSDK_HmsMessaging: turn on/off with AIDL
I/HMSSDK_HMSPackageManager: Enter getHMSPackageNameForMultiService
I/HMSSDK_HMSPackageManager: Enter getHMSPackageNameForMultiService
I/HMSSDK_HuaweiApi: No setInnerHms, hms pkg name is com.huawei.hwid
I/HMSSDK_HuaweiApi: sendRequest
D/HMSLogger: singleEventMap -> {apiName=getInitialNotification, package=com.ccc.app, cpAppVersion=2.6.6.1, version=6.3.0.304, platform=Cordova, result=0, costTime=0, service=Cross-Platform, kit=Push, appid=101754691, model=flame, networkType=WIFI, callTime=1691190441506}
I/HMSSDK_HMSPackageManager: Enter getHMSPackageName
I/HMSSDK_HuaweiApi: isConnected:true.
I/HMSSDK_BaseHmsClient: getAdapter:isInner:false, mInnerBinderAdapter:null, mOuterBinderAdapter:com.huawei.hms.adapter.OuterBinderAdapter@40ebfca
I/HMSSDK_HMSPackageManager: Enter getHMSPackageNameForMultiService
I/HMSSDK_HMSPackageManager: Enter getHMSPackageNameForMultiService
I/HMSSDK_RequestManager: addToConnectedReqMap
I/HMSSDK_HmsClient: post msg api_name:push.setNotifyFlag, app_id:101754691|, pkg_name:com.ccc.app, sdk_version:60800300, session_id:, transaction_id:101754691fyFlag20230804170721476343145, kitSdkVersion:60900300, apiLevel:1
I/HMSSDK_BaseAdapter: In constructor, activityWeakReference is java.lang.ref.WeakReference@83141fb, activity is com.ccc.app.MainActivity@3599851
I/HMSSDK_BaseAdapter: in baseRequest + uri is :push.setNotifyFlag, transactionId is : 101754691fyFlag20230804170721476343145
W/Parcel: Expecting binder but got null!
I/HMSSDK_PendingResultImpl: init uri:push.setNotifyFlag
I/HMSSDK_PendingResultImpl: setResultCallback
I/HMSSDK_PendingResultImpl: setResult:0
I/HMSSDK_HMSPackageManager: Enter getHMSPackageNameForMultiService
I/HMSSDK_BaseAdapter: api is: push.setNotifyFlag, resolution: null, status_code: 0
I/HMSSDK_HuaweiApi: No setInnerHms, hms pkg name is com.huawei.hwid
I/HMSSDK_BaseAdapter: baseCallBack.onComplete
I/HMSSDK_HMSPackageManager: Enter getHMSPackageNameForMultiService
I/HMSSDK_HuaweiApi: sendRequest
I/HMSSDK_HmsClient: receive msg status_code:0, error_code:0, api_name:push.setNotifyFlag, app_id:101754691|, pkg_name:com.ccc.app, session_id:
, transaction_id:101754691fyFlag20230804170721476343145, resolution:null
I/HMSSDK_HMSPackageManager: Enter getHMSPackageName
I/HMSSDK_TaskApiCall: doExecute, uri:push.setNotifyFlag, errorCode:0, transactionId:101754691fyFlag20230804170721476343145
I/HMSSDK_HuaweiApi: isConnected:true.
I/HMSSDK_BaseVoidTask: Operate succeed

Environment

  • Platform: [Cordova Cli - 11.1.0]
  • Kit: [Push - implementation "com.huawei.hms:push:6.9.0.300"]
  • Kit Version [ implementation "com.huawei.hms:hwid:5.0.3.302"]
  • OS Version [Android 13]

Other

Code inside my app in JavaScript

const initHuaweiPush = (props) => { //works
  HmsPush.init()

  HmsPush.turnOnPush()//works
    .then((result) => console.log("turnOnPush", result))
    .catch((error) => console.log("turnOnPush", error))

  HmsPush.getToken()//works
    .then((result) => {
      console.log("getToken", result)
      setRegistrationId(props, result)
    })
    .catch((error) => {
      console.log("getErrorToken", error)
    })


  HmsPushEvent.onNotificationOpenedApp((result) => {// doesn't work
    console.log("NOTIFICATION_OPENED_EVENT", JSON.stringify(result));
    const remoteMessageData = result.remoteMessage;
    const extrasData = result.extras;
    const uriPage = result.uriPage;

    alert("NOTIFICATION_OPENED_EVENT")
    alert(JSON.stringify(result))
    alert(remoteMessageData)
    alert(extrasData)
    alert(uriPage)
  })


  HmsPushEvent.onRemoteMessageReceived((result) => {// doesn't work
    const CordovaRemoteMessageObj = new HmsPush.CordovaRemoteMessage(result.msg);
    const msg = CordovaRemoteMessageObj.parseMsgAllAttribute(result.msg);
    console.log("Data message received : " + msg);
    alert('data message received')
    alert(JSON.stringify())
  })

}

Push payload send in postman

{
    //"validate_only": false,
    "message": 
    {
        "data": "{'param1':'value1','param2':'value2'}",
        "notification":
        {
            "title": "Huawei Push Kit",
            "body": "Hello, I'm a Push Kit."
        },
        "android":
        {
            "collapse_key": -1,
            "notification":
            {
                "icon": "notification_icon",
                "notify_id": 41186,
                "foreground_show": false, --> try with this on and off same result
                "badge": {
                   "add_num": 1,
                   "class": "com.ccc.app.MainActivity"
                },
                "click_action":
                {
                    "type": 3 ,//open app in tap,
                    "action":"com.ccc.app.MainActivity"
                }
            },

            "priority":"high",
            "delayWhileIdle":false
        },
        "token": ["KAAAAACy0xX3AAC4yG4Oun3XYVPW7Id8SC6Rd0MIcF6rKXWocHHzQg6LzJXXxySWu6Tifgr1Sxo2CMT49zK9RyeME4IOvE3E2uhztPaHUFhSTyJhrw"]
    }
}
@victor-sanchez-ccc victor-sanchez-ccc changed the title onNotificationOpenedApp call whitout result data onNotificationOpenedApp call without result data Aug 10, 2023
@victor-sanchez-ccc victor-sanchez-ccc changed the title onNotificationOpenedApp call without result data cordova-plugin-hms-push onNotificationOpenedApp call without result data Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant