Android User

Use NetmeraUser class to send information about your application's users to Netmera in a structured way.

Typical place to inform Netmera about application user's attributes is after your users has logged in to your application. After you have information about your logged in user, you should create a NetmeraUser object, set values, then call Netmera.updateUser() method like below.

Custom Profile Attributes:

It's important to note that while the parameters mentioned below are essential for your requests, you're not obligated to send all of them. They are optional and can be included based on your specific needs.

Additionally, if you wish to send a profile attribute that's not covered by these standard parameters, you can do so under the#custom-user title following a similar structure. This allows you to tailor your requests according to your unique requirements.

val netmeraUser = NetmeraUser()
netmeraUser.userId = "the_greatest"
netmeraUser.msisdn = "001XXXXXXXXX"
netmeraUser.email = "[clay@champion.com](<mailto:clay@champion.com>)"
[netmeraUser.name](<http://netmerauser.name/>) = "Muhammad Ali"
netmeraUser.surname = "Clay"
netmeraUser.externalSegments = listOf("sports", "box")
netmeraUser.gender = NetmeraUser.GENDER_MALE
netmeraUser.dateOfBirth = GregorianCalendar(1942, 1, 17).time
netmeraUser.maritalStatus = NetmeraUser.MARITAL_STATUS_MARRIED
netmeraUser.childCount = 9
netmeraUser.country = "USA"
netmeraUser.state = "Arizona"
netmeraUser.city = "Scottsdale"
netmeraUser.district = "Old Town Scottsdale"
netmeraUser.occupation = "Professional Boxer"
netmeraUser.industry = "Sports"
netmeraUser.favoriteTeam = "My Team"
netmeraUser.language = "English"
// Send data to Netmera
Netmera.updateUser(netmeraUser)

You can also update any attribute independent from the others.

If you need to remove a previously set attribute from Netmera, you must set null for corresponding attribute. Here is an example.

val netmeraUser = NetmeraUser()
// This will remove previously set `email` value from Netmera
netmeraUser.email = null
Netmera.updateUser(netmeraUser)

UserId cannot be removed:

userId cannot be removed even if you set null to it.

Send a single user update:

You should send a single user update request at a time.

Adding Custom Attributes to User

Similar to events, you can generate a custom NetmeraUser subclass using Netmera Dashboard if the set of built-in attributes is not enough for use case.

If the custom attribute is to be created on the Netmera, it must first be defined in the panel on (Developers->Profile Attributes).

Netmera will automatically generate the source files for your custom user class, so that you can easily use them to send information about your custom attributes.

Generated Code:

For all custom profile attributes, you can find the generated code at the bottom of the 'Profile Attribute' page under the 'Generate Code' section. Be sure to include this generated code in your Netmera Panel under the title Profile Attributes > User Class.

Private Info

The sharing of private datas are prohibited under KVKK law. In the profile and event definitions in the application, firstly the user defines the attributes in the Netmera panel. When the Private Information feature is selected while defining, the value of the attribute is not passed to the backend by the Netmera SDK. This check is done on the SDK side(Netmera.update(user)), the request does not go backend.

fetchCoupon

Utilize this method to retrieve and showcase the coupons that users have earned within your application.

val page = 0
val max = 10
Netmera.fetchCoupons(page, max,
    object : NMFetchCouponsResultListener {
        override fun onSuccess(coupons: List<NMCouponDetail>?) {
            if (coupons.isNullOrEmpty()) {
                // No coupons exist
            } else {
                // Use coupons
            }
        }

        override fun onFailure(error: String?) {
            // handle failure
            Toast.makeText(
                this@CouponActivity,
                error ?: "No error message",
                Toast.LENGTH_SHORT
            ).show()
        }
    })

User Update

You can continue using the existing method, and with version 3.11.1, you now have the option to listen for results by adding a listener.

Example Usage:

Netmera.updateUser(netmeraUser, new NMUpdateUserListener() {
    @Override
    public void onSuccess() {
        Log.i("Netmera App", "Netmera User was updated successfully");
        Toast.makeText(UpdateUserActivity.this, "NetmeraUser was successfully updated.", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onFailure(@Nullable String error) {
        Log.i("Netmera App", "Netmera User couldn't be updated successfully :: " + error);
        Toast.makeText(UpdateUserActivity.this, "Netmera User couldn't be updated successfully :: " + error, Toast.LENGTH_LONG).show();
    }
});

Last updated