Question

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

  • 3 August 2021
  • 6 replies
  • 183 views

Badge +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.


6 replies

Userlevel 5
Badge +10

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. 

Badge +2

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.

Badge +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!

Userlevel 5
Badge +10

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 +5

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 +5

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

Reply