uservoice / uservoice-android-sdk

UserVoice Android SDK
https://www.uservoice.com/mobile/
MIT License
117 stars 105 forks source link

How can I clear the user email? #245

Open geekarist opened 7 years ago

geekarist commented 7 years ago

Hello,

After the user submits the contact form with a comment, I would like to clear his email address so that later when displaying the contact form again, the email field is empty.

Is there a proper way to do it with the SDK?

I tried this: UserVoice.identifyUser(null, null, null) but somehow the SDK has a way to find the email back and fill in the contact form later.

I believe that this is where it happens: https://github.com/uservoice/uservoice-android-sdk/blob/master/UserVoiceSDK/src/com/uservoice/uservoicesdk/flow/InitManager.java#L84

Thanks for any help, Christophe.

snowpong commented 7 years ago

This worked for me:

    @SuppressLint("ApplySharedPref")
    private static void clearUser(Context context, Session session) {
        if (session != null) {
            session.setUser(context, new User());
            SharedPreferences.Editor edit = session.getSharedPreferences(context).edit();
            edit.remove("user_name");
            edit.remove("user_email");
            edit.commit();
        }
    }

call it with clearUser(context, Session.getInstance())