question

caleb avatar image
caleb asked caleb commented

Notifications Not Working

I've tried sending both app and device notifications and getting back 200 responses, but not receiving notifications. Same receiver is receiving other broadcast intents.


Are notifications working in sandbox and in general what is the duration between send and receive?

<receiver
    android:name=".ui.MyBroadcastReceiver"
    android:enabled="true"
    android:exported="true">
    <intent-filter>
        <action android:name="com.clover.sdk.app.intent.action.APP_NOTIFICATION" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</receiver>
class MyBroadcastReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        StringBuilder().apply {
            append("Action: ${
                  intent.action}\n")
            append("URI: ${
                  intent.toUri(Intent.URI_INTENT_SCHEME)}\n")
            toString().also { log ->
                Log.d(TAG, log)
                Log.d(TAG, intent.getStringExtra(EXTRA_APP_EVENT).toString())
                Toast.makeText(context, log, Toast.LENGTH_LONG).show()
            }
        }
    }
}
Intents
4 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.

caleb avatar image caleb commented ·

It actually is working for the application notification, but not for the device. I'm using the serial number as returned from the rest api. I've also tried the id and secureId values - is serial the right one?


    {
      "href": "https://sandbox.dev.clover.com/v3/merchants/XXX/devices/XXX",
      "id": "XXX",
      "model": "Clover_C503",
      "merchant": {
        "id": XXX"
      },
      "terminalPrefix": 0,
      "serial": "XXX",
      "secureId": "XXX",
      "buildType": "USER",
      "deviceTypeName": "GMC",
      "productName": "Station Duo",
      "pinDisabled": false,
      "offlinePayments": true,
      "offlinePaymentsAll": false
    }




0 Likes 0 ·
caleb avatar image caleb commented ·

Also note there is a limit on the length of the event string.

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·
It would help to know how you're creating the notification.
0 Likes 0 ·
caleb avatar image caleb commented ·

I was creating the notification via rest the rest api. This was the request to the merchant that worked. I couldn't get the one to `v3/apps/{aId}/devices/{deviceId}/notifications ` to work.

        let request = self
            .client
            .post(
                self.base_url
                    .clone()
                    .join(format!("merchants/{merchant_id}/notifications/").as_str())
                    .map_err(|e| AppError::UrlParseError(e))
                    .unwrap(),
            )
            .header(
                reqwest::header::AUTHORIZATION,
                format!("Bearer {clover_app_secret}").as_str(),
            )
            .header(reqwest::header::CONTENT_TYPE, "application/json")
            .body(serde_json::to_string(&notification_data).unwrap())
            .build()
            .unwrap();
0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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

Welcome to the
Clover Developer Community