question

thogan avatar image
thogan asked curtis commented

attempting first time setup of notification API

I am attempting to set up the notification api based on the following example: https://github.com/clover/android-exa... Once I implemented the solution I upload the APK and request approval. I then run the code on my clover mobile and attempt to make the rest call to the notification through the web page: https://sandbox.dev.clover.com/api_do... I have the API token and merchant ID set at the top of the page along with the app ID from the submitted app. I get back a result code of 0 with no body or error message back.

Should I be waiting for approval of the application or can I launch the app through android studio connected to the clover? I am not able to currently hit any of my breakpoints in android studio and the app does not respond to the REST call, so I am guessing that my app never receives the notification.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Mike M avatar image
Mike M answered curtis commented

It sounds like your token is not valid and is returning a 401 unauthorized, however, the api_doc's swagger UI seems to be blocking that response. Using the API or Android App for development has nothing to do with your application's approval status.

You can always double check the permission set of your token via: {cloverBaseUrl}/v3/access_tokens/{token}

For the app to work, you must install it via the App Market on your test merchant (I believe the app icon in the App Market will have a small banner stating "unpublished" at the top). After you install via the App Market, you can continue development via adb sideloading/installing via Android Studio. The initial App Market install is required to properly sync your access token to the device.

7 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

thogan avatar image thogan commented ·

Token call returns the following (with ID removed by me):

{"id": "---", "permissions": {"elements": [ {"name": "PAYMENTS_R"}, {"name": "EMPLOYEES_W"}, {"name": "ORDERS_W"}, {"name": "PAYMENTS_W"}, {"name": "CUSTOMERS_W"}, {"name": "MERCHANT_R"}, {"name": "INVENTORY_R"}, {"name": "MERCHANT_W"}, {"name": "INVENTORY_W"}, {"name": "CUSTOMERS_R"}, {"name": "ORDERS_R"}, {"name": "EMPLOYEES_R"}]}}

this returns 401 unauthorized: https://apisandbox.dev.clover.com/v3/apps/---/devices/---/notifications?access_token=---

0 Likes 0 ·
Mike M avatar image Mike M commented ·

Where are you getting the access token from? I think for any API that is app-scoped (/v3/apps/ as opposed to /v3/merchants/) requires the token to be associated to that specific app. Using a token from another app or generated via the web dashboard's Setup app will not work.

I just tested that hypothesis above with two different access tokens and was able to reproduce your issue with 1 token, and also solve it by using my other test access token (app scoped).

0 Likes 0 ·
thogan avatar image thogan commented ·

that would be it then, I am using the one generated from the dashboard. I will have one generated from the app.

0 Likes 0 ·
thogan avatar image thogan commented ·

I have generated one in the app and it seems that it is not working. the validated token is: https://sandbox.dev.clover.com/v3/accesstokens/a750e47f-16b8-f842-fb00-b4e355d9117c and the call I am making is https://apisandbox.dev.clover.com:443...token=a750e47f-16b8-f842-fb00-b4e355d9117c

0 Likes 0 ·
curtis avatar image curtis commented ·

I found that to send a notification from one rest/web app to an Android apk will only work if you're authed within the same Clover app and use the same app id. Doesn't look like you can send a notification from one Clover app id to another.

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community