Skip to main content
Question

How do I set attributes with Cordova? It always returns invalid.


Forum|alt.badge.img+5

When I am setting attributes with Cordova whether generically like this:

Purchases.setAttributes({“age”: “24”});

Or when using something like the display name like this:

Purchases.setDisplayName(“Doe”);

I always end up with an error message that looks like this:

To Native Cordova ->  PurchasesPlugin setAttributes INVALID ["options": [{
    age = 24;
}]]

Or this for the display name:

To Native Cordova ->  PurchasesPlugin setDisplayName INVALID ["options": [Doe]]

 

Am I missing something? I went through and updated everything in my app to be uptodate. I am using the following versions of things:

"@ionic-native/core": "^5.35.0",
"@ionic-native/purchases": "^5.35.0",
"cordova-plugin-purchases": "^2.3.0",

Everything else with purchases is working just fine as far as I can tell, I just can’t seem to use it to set an attribute.

tina
RevenueCat Staff
Forum|alt.badge.img+10
  • RevenueCat Staff
  • August 5, 2021

Hi @Asher!

That error is actually not something that RevenueCat throws, it looks like it’s coming from the system. Just to confirm, are you calling the setAttributes(...) and setDisplayName(...) after calling setup


Forum|alt.badge.img+5
  • New Member
  • August 5, 2021

Yes this is the current order I run things:

Purchases.setDebugLogsEnabled(true);

Purchases.setup("publicKey", 'UserID');

Purchases.setAttributes({“age”: “24”});

All of this runs in  function onDeviceReady()


Forum|alt.badge.img+5
  • New Member
  • August 5, 2021

Oops I accidentally clicked best answer and it doesn’t seem like there is a way to undo that. :sweat:


tina
RevenueCat Staff
Forum|alt.badge.img+10
  • RevenueCat Staff
  • August 5, 2021

Hey @Asher!

No worries, I just removed the best answer. I will forward your request into our ticketing system to collect some additional information and will post back here once we figure out what’s going on. 


Forum|alt.badge.img+3

So I just checked and JavaScript/Typescript doesn’t like the kind of quotes you used in the array {“age”: “24”});

This could of course be to styling on the RevenueCat webpage but the Public Key in the line above has the correct double quotes. Worth a shot!


Forum|alt.badge.img+3

Hello, @Asher Did you solve the issue you faced?

I am getting the same error like you in my ionic capacitor project.

PurchasesPlugin setAttributes INVALID ["options": [{

    "$displayName" = test;

    "$email" = "test@gmail.com";

    "$firebaseAppInstanceId" = K3Qnk3yQQ7qGeIAENofl;

    adultType = "";

    childType = "";

}]]

but that worked sometimes, I am not sure what I am missing.

I want to solve this issue.

Thanks.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings