question

ycb avatar image
ycb asked Mark Mullan Deactivated commented

Problem with CustomerIntent.ACTION_CUSTOMER_UPDATE

I can not receive intent when I use this action

<action android:name="com.clover.sdk.customer.intent.action.CUSTOMER_UPDATE"/>

Customers
10 |2000

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

Mark Mullan avatar image
Mark Mullan Deactivated answered

Hi @yc,

I'm receiving Intents fine with this broadcast. Please note the documentation for CustomerConnector.getCustomer() and note that the Intent is only conditionally fired:

This call will return immediately with the local version of the customer if one exists on the device, it will then contact the server to check for an updated version. If a new version exists a
{com.clover.sdk.v1.customer.CustomerIntent#ACTION_CUSTOMER_UPDATE} broadcast will be sent.

In your AndroidManifest.xml, declare the BroadcastReceiver and specify the com.clover.sdk.customer.intent.action.CUSTOMER_UPDATE broadcast action that the receiver subscribes to:

<receiver android:name=".MyBroadcastReceiver"  android:exported="true">
    <intent-filter>
        <action android:name="com.clover.sdk.customer.intent.action.CUSTOMER_UPDATE"/>

    </intent-filter>
</receiver>

Then implement the Java:

public class MyBroadcastReceiver extends BroadcastReceiver {
    private static final String TAG = "MyBroadcastReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        StringBuilder sb = new StringBuilder();
        sb.append("Action: " + intent.getAction() + "\n");
        sb.append("URI: " + intent.toUri(Intent.URI_INTENT_SCHEME).toString() + "\n");
        String log = sb.toString();
        Log.d(TAG, log);
        Toast.makeText(context, log, Toast.LENGTH_LONG).show();
    }
}
10 |2000

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

ycb avatar image
ycb answered Mark Mullan Deactivated commented

Thanks Mark.

I thought that the broadcast is sent if a any change made at the server. So if I want to receive the broadcast I have to use CustomerConnector.getCustomer() ?

1 comment
10 |2000

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

Mark Mullan avatar image Mark Mullan commented ·

Yes! Correct.

0 Likes 0 ·

Welcome to the
Clover Developer Community