question

ycb avatar image
ycb asked ·

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"/>

CustomersIntents
10 |2000 characters needed characters left characters exceeded

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 ·

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 Share
10 |2000 characters needed characters left characters exceeded

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

Yes! Correct.

0 Likes 0 · ·
Mark Mullan avatar image
Mark Mullan 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();
    }
}
Share
10 |2000 characters needed characters left characters exceeded

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