philmerrell / capacitor-firebase-analytics

Capacitor plugin that integrates Firebase Analytics for Android and iOS
17 stars 22 forks source link

'setUserId' operation must accept null #14

Open vitorplopes opened 4 years ago

vitorplopes commented 4 years ago

Hi @philmerrell ,

According to Firebase setUser operation docs:

The user ID to ascribe to the user of this app on this device, which must be non-empty and no more than 256 characters long. Setting the ID to null removes the user ID.

Plugin does not allow null values, as follows:

@PluginMethod()
    public void setUserId(PluginCall call) {
        try {
            final String userId = call.getString("userId");
            if (userId != null) {
                firebaseAnalytics.setUserId(userId);
                call.success();
            } else {
                call.reject("key 'userId' does not exist");
            }
        } catch (Exception e) {
            call.reject(e.getLocalizedMessage(), e);
        }
    }

Best regards,

Vitor Pires Lopes