cancel
Showing results for 
Search instead for 
Did you mean: 

Kapsel Push notification using HCPMS with REST client, problem is to trigger notification on to the device

0 Kudos

Hi all,

     i have developed a kapsel push notification cordova based app which is linked to my HCPms cockpit and i followed the below document to develop.

and

App successfully registered with HCPms, and i could see the APP registred ID in cockpit : ed0f5105-2bc4-4xxxc5-axxx-bxxxxxxxxxxx, 

where the others requirements are as follows

API Key : AIzaSyAxxxXXXOo0OC0npExxx4XaD8tHCqvBQxx

Sender ID : 2982XXXXXXXX

Notification user  has been assinged in the HCPms.

Turned on push service in GCM.

APPCID : ed0f5105-2bc4-4xxxc5-axxx-bxxxxxxxxxxx.

Android.Manifest file has been configured correctly by adding required permissions and plugins


Now i am able to register and unregister from my HCPms cockpit but could able to send the push notification to my app on android device.

the below is the url i found to trigger the notifications on my HCPms.

https://hcpms-pXXXXXXXXXtrial.hanatrial.ondemand.com/Notification     - which is mentioned in my HCPMS

but when my device is registered i am got as


https://hcpms-pXXXXXXXXtrial.hanatrial.ondemand.com:443/com.push.customer/odata/applications/latest/...')


So what is the exact way to trgger the notification and did i missed any thing else.

I tried the above one and tried other ways to trigger using REST client but couldnt able to get succeed and i am getting "403 FORBIDDEN" error .


1. Install POSTMAN in your Google Chrome browser.

2. Start POSTMAN. Adding True Mobile Capabilities 12.6 © Rheinwerk Publishing, Boston 2015 49

3. Select Basic Auth.

4. Enter your SAP HCP user credentials.

5. Select Post as the HTTP Method to Execute.

6. Select the destination URL: https://hcpms-trial.hanatrial.ondemand.com/restnotification/application/com.hcpbook.hybrid This URL format is used to notify all users of the specified application. (Note: The synopsis of your SAP HCPms application definition shows a push URL, but it is not quite correct in the current release of SAP HCPms; replace /Notification with /restnotification as shown previously.)

7. Add a Content-Type HTTP header; set the value to application/json.

8. Select Raw and JSON for Content Type.

9. Add the following payload message text: {"alert":"Your latest meme is available for review", "data": "foo" }.

10. Click Send.


So can any one help me out what the exact way to trigger the notification to my registered device.

pls find the attached images to get clarification.





Accepted Solutions (1)

Accepted Solutions (1)

midhun_vp
Active Contributor
0 Kudos

Hi Saikiran

Please note the below steps when you are testing the push notifications with HCPms.

  • Note that the sender ID is your GCM project ID.

  • Find the request URL, headers and body from the below screen shots.

  • HCPms application configurations are given below:

I have tested push against HCPms and found it working with an android device version 5.

Regards,Midhun

SAP Technology RIG

0 Kudos

Hi Midhun ,

     Firstly thanks a lot for the response.

Last time itself i have followed each and every step exactly as u mentioned above and my API Key(Server) is shown in the attachment. Is that right?  Presently i am facing problem with my HAT ,so as soon as it got fixed i will try to cross check the above all and say you where i got strucked.

midhun_vp
Active Contributor
0 Kudos

Hi Saikiran,

You are right. You need to provide the server API key. Also note that you need to use the gcm.jar file in your project as mentioned in this blog:

Regards,Midhun

SAP Technology RIG

0 Kudos

Hi Midhun,    

     Yes i have included in platform->android->libs folder then i have build my app again to generate apk file.

Regards,

Saikiran Bommagowni

midhun_vp
Active Contributor
0 Kudos

Hi Saikiran,

Is it working now ?

You could have a look at this blog to get more details: http://enterprisemobilityblog.com/android-push-notifications-with-hcpms/

Regards,Midhun

SAP Technology RIG

0 Kudos

Hi Midhun,

     I have done every thing again with latest SDK and followed each and every step perfectly but still no luck.

     My main problem is to trigger a notification from the rest call. I am new to that REST call. I am getting 405 error if my url is as below

https://hcpmsadmin-p19411XXXXXtrial.dispatcher.hanatrial.ondemand.com/restnotification/application/c...

firstly how would i know that my device is registered using GET ?

and what all the headers i need to pass?

do i need to pass AppCID? if so how would i get using rest call?

i have tried various ways

https://hcpmsadmin-p19411XXXXtrial.dispatcher.hanatrial.ondemand.com/restnotification/application/co...

And my mobile giving the registration info as

And when i click register for push its giving the id as

So how can i trigger the notification using REST .why i am getting the 405 error .

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

By looking at last screenshot, its clear that your device has been registered with GCM server. In fact, you can verify it using REST client,

Make a GET request,

hcpms-<SCNuserid>trial.hanatrial.ondemand.com/odata/applications/latest/com.test.hcpms/Connections('x-smp-appcid value')

Header: X-SMP-APPCID: value

in the RESPONSE, you would notice the same GCM Registration ID for the parameter 'AndroidGcmRegistrationId'

then to send/trigger a notification from the REST client, request a POST

https://hcpmsadmin-p19411XXXXtrial.dispatcher.hanatrial.ondemand.com/restnotification/application/co...

Headers:

Authorization: SCN id and password

content-type:application/xml

<<please share the Request Header screenshot if still you dont get the notification>>

Regards,

JK

0 Kudos

Hi JK,

     Thanks for the response. I got the status 200(OK) for GET but i didnt get the AndroidGCMRegistrationID as of your screen shot, I got the response as shown in the below figure.

And when i tried to triggered notification i got the response as status 200, but i didnt get any notification. And how would i know that a notification has been triggered successfully through  response headers. The following is the POST request screen shot .

i think i am near to get it work ,so pls help me out.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

You will see 'AndroidGCMRegistrationID' under RESPONSE BODY not under RESPONSE HEADER.

Please confirm if you see its value.

Coming to '200 OK' message for Push notification,

In general, this could be because App hasnt received GCM id or could be an issue reaching the GCM service.

Regards,

JK

0 Kudos

Hi JK,

     Now i am using the postman REST so i for the GET request i got the GCM ID as shown in the below attachment.

Now when i did the POST request i am getting the status 200 but it is giving the error as "your browser doesnt support java script ", i checked it in my browser setting it is perfect and enabled for all sites.the following is the attchement for the post request.

and i have assigned the notification user in the SAP HANA Cloud Platform Mobile Services too as shown in the below attachment.

and i have kept the "gcm.jar" in my libs folder too so what would be my problem to trigger the notification.

regards,

Saikiran Bommagowni.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Can you cross verify if JS has been enabledd in the web browser? check this

Calling Dan to share his views on above.

Regards,

JK

0 Kudos

Hi JK,

     I have cross verified it . The below image gives confirmation.

Regards,

Saikiran Bommagowni.

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

The content within a noscript tag will be displayed on the screen if the browser does not have JavaScript enabled.  I believe you are seeing that because you are looking at the HTML that has not been rendered.

The one thing I noticed is that the Content-Type header is not set to application/json.

Hope that helps,

Dan van Leeuwen

midhun_vp
Active Contributor
0 Kudos

Hi Saikiran,

What I could notice is that the url you are using is wrong. You should not add the word admin in the URL. Please follow the below url format.

Regards, Midhun

SAP Technology RIG

0 Kudos

Hi Midhun,

     You were right.But now i am getting the 503 service unavailble error.what would be the reason.

midhun_vp
Active Contributor
0 Kudos

Hi Saikiran,

You have to look at the complete URL, you should remove the dispatcher as well from the URL.

Regards, Midhun

SAP Technology RIG

0 Kudos

Hi Midhun,

     sorry for that mistake. i got the response now but didn't got the notification on my registered mobile.And it is showing my mobile registration ID as "registrationId": "5c5aa9b1-cd3a-494d-9d0c-424db5ae7471" in the response body.

0 Kudos

Hi midhun,

I am getting the response as below.

{

    "status": {

        "value": "OK",

        "code": 0

    },

    "results": [

        {

            "status": {

                "value": "Unknown push target type",

                "code": 2

            },

            "registrationId": "ae0efb76-bcb2-4011-898e-531eb98fd60b"

        },

        {

            "status": {

                "value": "Unknown push target type",

                "code": 2

            },

            "registrationId": "f999d271-ce96-4b82-8609-94b52734b2b3"

        },

        {

            "status": {

                "value": "Unknown push target type",

                "code": 2

            },

            "registrationId": "3eab9bd4-888f-4781-9a6a-e007dfb6db66"

        },

        {

            "status": {

                "value": "OK",

                "code": 0

            },

            "registrationId": "81ee087b-0bb5-48f4-9766-729bd6db1c4e"

        },

        {

            "status": {

                "value": "OK",

                "code": 0

            },

            "registrationId": "5c5aa9b1-cd3a-494d-9d0c-424db5ae7471"

        }

    ]

}

midhun_vp
Active Contributor
0 Kudos

Hi Saikiran,

Could you delete all the existing registrations to that application from HCPms cockpit and redo the whole steps again (login>register for push>test from rest client).

Regards, Midhun

SAP Technology RIG

midhun_vp
Active Contributor
0 Kudos

Hi Saikiran

Is there any updates on this?

Regards, Midhun

SAP Technology RIG

0 Kudos

Hi Midhun,

     I have some problem with my sdk as i have upgraded to SP09 ,so i am facing some problem. I will inform you as soon as it is done.

Regards,

Saikiran Bommagowni.

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Note that the plugin ID's changed in SP09 of the SDK.  There is an upgrading section to the Getting Started Guide that might be of some help.

Regards,

Dan van Leeuwen

Answers (4)

Answers (4)

0 Kudos

Hi Midhun/Jitendra,

     Thanks a lot for your help ,now i am able to get the notifications successfully on my device with SMP SDK SP08 . Now i will try for the SMP SP09 SDK and also with SMP local server rather than HCPMS cloud server. Sorry for the late reply as was involved in some other work so i couldn't able to work on the notifications.

Regards,

Saikiran Bommagowni.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Were you able to make push notification work? Has your issue resolved?

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos


but when my device is registered i am got as


https://hcpms-pXXXXXXXXtrial.hanatrial.ondemand.com:443/com.push.customer/odata/applications/latest/...')


please check again, It should be

https://hcpms-pXXXXXXXXtrial.hanatrial.ondemand.com:443/odata/applications/latest/com.push.customer/...')

This one is just a response for the POST request (register an user/on-boarding a device).


What happens when you try with below URLs


https://<HMC base URL>/restnotification/application/<applicationId>

https://<HMC base URL>/restnotification/application/<application ID>/user/<username>


I also suggest you to make a GET request to this URL


https://hcpms-pXXXXXXXXtrial.hanatrial.ondemand.com:443/odata/applications/latest/com.push.customer/...')

Header: x-smp-appcid:<value>


and check the response , do you see a value for AndroidGcmRegistrationId parameter?


Regards,

JK

0 Kudos

Hi all,

     can any one help me to figure out this problem