I'm trying to set a custom attribute into the marketing cloud mobile push SDK. The attribute class is abstract class but has a method that returns Attribute.

public static Attribute a(String var0, String var1) {
    return new b(var0, var1);

My question is why this is Restricted and obfuscated? As there is a public method to set Attribute

 RegistrationManager.Editor setAttribute(@NonNull Attribute var1);`

I would assume its intended to set an attribute by providing the parameter of type Attribute.


It was originally a mistake for the create method in the Attribute class to be obfuscated/restricted. When we decided to address this we also decided that we would deprecate this class, and eventually remove it from the SDK. The deprecation should be reflected in an upcoming release.

Even with a current version of the SDK you would be able to modify the value of an Attribute in the registration. The RegistrationManager.Editor class has a setAttribute method which takes in as its parameter a String for the key and a String for the value.
@NonNull RegistrationManager.Editor setAttribute(@NonNull String key, String value)

  • So basically this method shouldn't be used at all? Instead setAttribute(String, String) should be used? Also I noticed with setAttribute(Attribute), if I provide the same key again, its add a new attribute and doesn't update the existing attribute with same key. – S.Javed Feb 1 '18 at 13:48
  • Which version of the SDK are you using? – Bill Mote Feb 1 '18 at 13:54
  • This issue I saw on 5.1.3. Now I'm using the 5.4.2 with find and replace attribute logic. – S.Javed Feb 1 '18 at 14:34
  • I can reproduce the issue of the same Attribute key value ending up in the Attributes list, but on if I set that key twice with the same Editor instance. Is that also what you're seeing? – Seth Feb 1 '18 at 15:51
  • I'm calling setting up the attribute like this MarketingCloudSdk.requestSdk(new MarketingCloudSdk.WhenReadyListener() { @Override public void ready(MarketingCloudSdk marketingCloudSdk) { RegistrationManager registrationManager = marketingCloudSdk.getRegistrationManager(); registrationManager .edit() .setContactKey(contactKey) .setAttributes(Attribute.a(ARG_USER, getUserName()) .commit(); } }); – S.Javed Feb 5 '18 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.