1

I've implemented MC Cordova Plugin (https://github.com/salesforce-marketingcloud/MC-Cordova-Plugin) for push notification through Marketing Cloud for hybrid mobile app, but encountering problems to clear and set Attribute.

The first time I install the app, clearAttribute and setAttribute will work perfectly. But after update the data and triggering clearAttribute and setAttribute the next time, values are not updated.

For example, in this scenario I want to update attribute everytime I log in to a new user :

log out -> call clear Attribute logged in -> set Contact Key and set Attribute

the first user data is updated using contact key and set attribute (e.g. value : "abc"), the first time I logged out, the value is cleared too. (e.g. value : "")

However, after 2nd and more attempt, the value from variable in attribute will not updated by using set attribute(e.g. new value should be "def", but in attribute still value : "abc"), and not cleared using clear Attribute after log out (e.g. still -> value : "abc").

FYI the return is SUCCESSFUL from the plugin (for Android the return is "OK")

I've used Java 1.8, Cordova 7.0.0, Android Cordova v.6.3.0

MC Cordova Plugin version : 2.0.0 com.salesforce.marketingcloud.cordovaplugin

Snippet Code :

document.addEventListener("deviceready",()=>{
   MCCordovaPlugin.setContactKey((success) =>{
       console.log("success set contact key");
       console.log(success);
       }, (error) => {
       console.log("error set contact key");
       console.log(error);
   }, this.contactKey); 

   MCCordovaPlugin.getContactKey((success) =>{
       console.log("success GET contact key");
       console.log(success);
       }, (error) => {
       console.log("error GET contact key");
       console.log(error);
   });

   MCCordovaPlugin.setAttribute((success) =>{
       console.log("success set attribute ID");
       console.log(success);
       }, (error) => {
       console.log("error set attribute ID");
       console.log(error);
    }, "NewID", this.contactKey);

}, false);

Kindly need your help about this behavior, thanks a lot!

Regards,

0

I'm set-up the same versions you are using. Java 1.8, Cordova 7.0.0, Android Cordova v 6.3.0 but with latest Cordova plugin 1.0.3 on our public repo testing on Android emulator using emulator Nexus 6 API_26 Android O on Android 8.0.0.

I was able to set attributes and clear them both through the app foreground to background and back to foreground transitions, as well as remove the app from memory relaunch it several times and either the cleared attributes or new attributes were still present. So it seems like things are testing correctly on my end.

Some questions. 1. What do you mean by logged in and logging out in your app? Are you relaunching the entire plugin and by chance re-initing values from scratch? 2. Can you verify with console logs if you are indeed calling your JS MCCordovaPlugin.setAttribute((success) =>{... function every time you attempt to set and clear attribute values? 3. I'm not seeing your entire implementation in your example so it's difficult to tell if the issue may be in the JavaScript "document.addEventListener("deviceready",()=>{..." side or somewhere else.

  • Hi Tom, thanks for the reply! Apparently I am still using the plugin ver. 1.0.2, and just know there is an update. When I used 1.0.3, it works like charm ! Thanks for that :) – Lyon Stark May 8 '18 at 4:51
  • Awesome! Let me know if I can help further. – Tom Brooks May 8 '18 at 13:06

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.