Mobile SDK Android: EPZConstants

From ePrize Developers Wiki

(Difference between revisions)
Jump to: navigation, search

Current revision

Overview

The EPZConstants class is a simple storage class for constants defined for use in the SDK, and as a convenience for applications using the SDK, so they can make use of the constants as needed (e.g. to avoid typos in string values, to use when defining dictionary keys for configuration options, etc).


Code Samples

Below are a few examples of instances where you may wish to make use of these constants in this class.

Note: Due to the number of constants defined in this class, they are not listed here. You can view the full list of constants in the EPZConstants.java file in the EPrizeMobileSDK library.


Configuring the EPZPromoLibrary and EPZPushNotificationService

private static final String CLIENT_KEY_PUBLIC = "dev_multi";
private static final String PUSH_KEY_PUBLIC = "push_dev_multi";
private static final String GCM_SENDER_ID = "334651628650";

Map<String, Object> configOptions = new HashMap<String, Object>();
configOptions.put(EPZConstants.CONFIG_KEY_CLIENT_KEY, CLIENT_KEY_PUBLIC);
configOptions.put(EPZConstants.CONFIG_KEY_APP_CONTEXT, this);
configOptions.put(EPZConstants.CONFIG_KEY_GCM_SENDER_ID, GCM_SENDER_ID);
configOptions.put(EPZConstants.CONFIG_KEY_PUSH_KEY, PUSH_KEY_PUBLIC);

Checking the eventName property on the EPZPushPreferencesViewLifecycleEvent

@Subscribe
public void handlePushPreferencesViewLifecycleEvent(EPZPushPreferencesViewLifecycleEvent event) {
    if (event.eventName.equals(EPZConstants.LIFECYCLE_EVENT_OPEN)) {
        // Handle as desired.
    }
}
Personal tools