Is it required to Register a Terminal App before testing Poynt Cloud Messaging?

After creating a sample application as described in here -> Here,If I try to send a cloud message using Post request, I get an unauthorized access error
as below

{ "code": "UNAUTHORIZED_ACCESS", "httpStatus": 401, "message": "Access not authorized for the requested resource.", "developerMessage": "co.poynt.samples' does not match sender application package name." }

postman request body as follows

{ "deviceId":"----------------------------------", "businessId":"----------------------------------", "storeId":"----------------------------------", "recipient":{ "packageName":"co.poynt.samples", "className":"MyBroadcastReceiver" }, "ttl":500, "data":"test Message" }
Any reason why this might fail? Do I need to create a Terminal App on
this and register my app package name before sending a message?

I have registered my app on poynt.net
And tried using the sample python application provided by poynt as mentioned in the tutorial. But this time it shows this error

POST https://services.poynt.net/cloudMessages HTTP RESPONSE CODE:401 HTTP RESPONSE CODE:{"code":"UNAUTHORIZED_ACCESS","httpStatus":401,"message":"Access not authorized for the requested resource.","developerMessage":"Unauthorized access attempt. This principal does not have access to this resource.","requestId":"5b5ea3f8-85a8-4e17-9e60-a3354857e4ae"} RESPONSE TIME: 1289.659 msecs Request merchant authorization by sending them to: https://poynt.net/applications/authorize?callback=http%3A%2F%2Falavilli.com%2Fdump.php&applicationId=urn%3Aaid%3Af9f40221-977a-4c33-8460-1c098d8d98cb&context=python-test-script

What should I do

DO I Need to Submit the app for Review to use cloud messaging

Hi there,

We currently have to manually enable app ids to send cloud messages. We’ll get yours enabled today and I will let you know when you can run your test.

1 Like

Thank you @dennis eagerly waiting to test the app

We’ve enabled your app id. One more thing you will need to do is create an authorization URL as explained in step 8.1 of https://poynt.github.io/developer/tut/integrating-with-poynt-cloud-apis.html, log in and authorize access using your test merchant (use the same credentials as what you use for your dev org).
All of this will be taken care of automatically when an app is installed by merchants.

1 Like

Thanks for the reply, I am able to send an action successfully through cloud messaging

poyntAPI.sendCloudMessage(BUSINESS_ID, STORE_ID, "", "", "{\"action\":\"authorize\", \"purchaseAmount\": 1000, \"tipAmount\": 100, \"currency\":\"USD\", \"referenceId\":\"ABC1234\", \"orderId\":\"hello-order-id\", \"callbackUrl\":\"http%3A%2F%2Frequestb.in%2F11odyf81\"}")

But still I am unable to send a simple message,

#poyntAPI.sendCloudMessage(BUSINESS_ID, STORE_ID, "com.test.samples1991", "com.test.samples1991.MyBroadcastReceiver", "Hello from the cloud.")

Once I send the request I get a response as follows

POST https://services.poynt.net/cloudMessages HTTP RESPONSE CODE:401 HTTP RESPONSE CODE:{"code":"UNAUTHORIZED_ACCESS","httpStatus":401,"message":"Access not authorized for the requested resource.","developerMessage":"com.test.samples1991' does not match sender application package name.","requestId":"44ed3f88-ae88-4dc7-bcca-04a7b6d6f1c1"} RESPONSE TIME: 2159.947 msecs Request merchant authorization by sending them to: https://poynt.net/applications/authorize?callback=https%3A%2F%2Fgoogle.com&applicationId=urn%3Aaid%3A41e6500b-01e6-4760-ae7f-8c7e5b247aae&context=python-test-script

I have authorized the url and the callback url is redirected successfully.

Concerns

I’m not using the Certificates That I got during terminal app creation,
The app Id and the package name I’ve sent Poynt support to enable the app are as follows

  • Terminal App ID (Not Cloud App ID)

  • Package Name of the terminal app that uses the BroadcastReceiver class for cloud messaging as explained in here

You have to use the public/private key pair that was issued for your terminal app id, otherwise your call will fail. If you did not download the keypair you can reset it on poynt.net.

I’ve set the following in poynt.in file

APPLICATION_ID -> cloud app ID PRIVATE_KEY_FILE -> private key obtained from terminal app PUBLIC_KEY_FILE -> public key obtained from terminal app
and I have set the following in poyntAPI.py getAccessToken() method

payload = { 'exp': expiryDatetime, 'iat': currentDatetime, 'iss': 'terminal app ID',<------ Terminal App ID 'sub': self.applicationId, <----- Cloud App ID 'aud': 'https://services.poynt.net', 'jti': str(uuid.uuid4()) }

and now I get a response as follows

POST https://services.poynt.net/cloudMessages
HTTP RESPONSE CODE:202
HTTP RESPONSE BODY:
RESPONSE TIME: 1218.033 msecs
Successfully sent cloud message.
`
But I am still not getting any push notification to the device. Please note that I’m using Genymotion as the emulator

Can you do “adb logcat” and rerun the script? You should see log entries if the cloud message is making it to the emulator.
Can you also post your receiver class configuration as you have it in your app’s manifest?

I have verified that cloud messaging is working properly in the emulator. Things to double check on your side:

  1. Receiver class configuration in app manifest is correct (https://poynt.github.io/developer/tut/poynt-cloud-messages.html)

  2. You are specifying correct package name and receiver class name in the cloud message

  3. You can see the cloud message reaching your emulator when you tail logcat. You should see something like this:

    02-16 10:07:55.875 I/POYNT-EVENT( 2310): {“time” : “2016-02-16T18:07:55Z”, “type” : “WEBSOCKET”, “resource” : “”, “status” : “INFO”, “processingTime” : 0.0, “method” : “”, “apiStatusCode” : 0, “apiEndpoint” : “”, “sdkErrorCode” : 0, “data” : “co.poynt.api.model.CloudMessage”}
    02-16 10:07:55.875 I/POYNT-EVENT( 2310): {“time” : “2016-02-16T18:07:55Z”, “type” : “CLOUD_MESSAGE”, “resource” : “urn:tid:9d8646a0-4088-3e88-816d-67d26862dd0e-6”, “status” : “INFO”, “processingTime” : 0.0, “method” : “MSG_RECEIVED”, “apiStatusCode” : 0, “apiEndpoint” : “”, “sdkErrorCode” : 0}

Thanks @dennis it’s working I just received the message,

I/POYNT-EVENT( 1022): {"time" : "2016-02-17T04:04:36Z", "type" : "WEBSOCKET", "resource" : "", "status" : "INFO", "processingTime" : 0.0, "method" : "", "apiStatusCode" : 0, "apiEndpoint" : "", "sdkErrorCode" : 0, "data" : "co.poynt.api.model.CloudMessage"}
I/POYNT-EVENT( 1022): {"time" : "2016-02-17T04:04:36Z", "type" : "CLOUD_MESSAGE", "resource" : "urn:tid:165841fb-0b91-3757-856f-ca7fc56b76b8-17", "status" : "INFO", "processingTime" : 0.0, "method" : "MSG_RECEIVED", "apiStatusCode" : 0, "apiEndpoint" : "", "sdkErrorCode" : 0}
D/MyBroadcastReceiver( 1628): Got cloud Message: Hello from the cloud.

And this is my manifest.xml

<receiver
            android:name="com.test.samples1991.MyBroadcastReceiver"
            android:enabled="true"
            android:exported="true" >
            <intent-filter>
                <action android:name="poynt.intent.action.CLOUD_MESSAGE_RECEIVED" />
                <category android:name="poynt.category.CLOUD_MESSAGE" />
            </intent-filter>
</receiver>

Broadcast Receiver class

 public MyBroadcastReceiver() {
    }
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("MyBroadcastReceiver", "Got cloud Message: " + intent.getStringExtra(Intents
                .INTENT_EXTRA_CLOUD_MESSAGE_BODY));
    }

Awesome! Looking forward to seeing your app in action.

1 Like

Hi Dennis,
Can you enable please this applicationId to send Cloud Notifications?
urn:aid:be349d34-f943-4c79-b5c0-93852b7e076f
Thank you.

1 Like

Hello,

Can you login to poynt.net and go to Developer > Cloud Apps and then click on Manage (wrench icon) for your application. Use your test merchant to log in on the merchant login URL to authorize your app id.

1 Like

Hi Dennis, i have done that but i still receive the 401 error code:
{ "code": "UNAUTHORIZED_ACCESS", "httpStatus": 401, "message": "Access not authorized for the requested resource.", "developerMessage": "co.poynt.thinkpink.MyBroadcastReceiver' does not match sender application package name.", "requestId": "89a75677-af4e-48bd-a70d-b52517fff4f5" }

I have granted the permissions, in fact all permissions but still get this error. Meantime when i come back to the cloud app page, the grant permissions combo box always has the selected option “grant to test merchant…” is this the normal behaviour?
Regards

1 Like

Hi Paulo,

urn:aid:be349d34-f943-4c79-b5c0-93852b7e076f is a cloud app id. It cannot be used to send messages to an application running on the terminal because it is not associated with your app’s package name.

This is a bit of a manual process at the moment. So what you need to do it upload your app’s apk at https://poynt.net/terminalapps/add. Once you do that you will be issued a new app id which will be associated with your app’s package name (Note: your package name should not start with “co.poynt” which is reserved for Poynt apps) and a private key.

After that you will need to use your test merchant to authorize the app id to send cloud messages. This is step 8 at https://poynt.github.io/developer/tut/integrating-with-poynt-cloud-apis.html.

1 Like

Thank you Dennis! It’s working now :smile:

1 Like

Hi @dennis just wanted to verify if cloud messaging would work with android studio emulator.

Yes, cloud messaging works with the emulator.