Question

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

  • 3 August 2021
  • 4 replies
  • 56 views

Badge +1

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.


4 replies

Userlevel 3
Badge +8

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

Badge +1

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()

Badge +1

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

Userlevel 3
Badge +8

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. 

Reply