prebid / prebid-mobile-android

Prebid Mobile SDK for Android applications
Apache License 2.0
58 stars 84 forks source link

Json conversion in ExternalUserId class for Android differs from IOS' #798

Open hyungonkim-StroeerNZ opened 2 months ago

hyungonkim-StroeerNZ commented 2 months ago

Version 2.2.3

Converting to JSON string in the ExternalUserId class differs between iOS and Android.

I guess no one uses this method, but I found this.

The "atype" in both platforms is stored into the different name Android is stored as "adtype" and IOS is stored as "atype"

In Android.

public JSONObject getJson() { JSONObject result = new JSONObject();

    if (getSource() == null || getSource().isEmpty() || getIdentifier() == null || getIdentifier().isEmpty()) {
        return null;
    }

    try {
        JSONObject uidObject = new JSONObject();
        uidObject.putOpt("id", getIdentifier());
        uidObject.putOpt("adtype", getAtype());  <<<<< HERE
        if (getExt() != null) {
            uidObject.putOpt("ext", new JSONObject(getExt()));
        }

        result.put("source", getSource());
        result.put("uids", new JSONArray().put(uidObject));
    } catch (JSONException e) {
        LogUtil.warning("ExternalUserId", "Can't create json object.");
        return null;
    }

    return result;
}

In IOS.

public func toJSONDictionary() -> [AnyHashable: Any] { guard source.count != 0 && identifier.count != 0 else { return [:] } var transformedEUIdDic = [AnyHashable: Any]() transformedEUIdDic["source"] = source

    var externalUserIdDict = [AnyHashable: Any] ()
    externalUserIdDict["id"] = identifier
    externalUserIdDict["atype"] = atype    <<<<< HERE
    externalUserIdDict["ext"] = ext

    transformedEUIdDic["uids"] = [externalUserIdDict]
    return transformedEUIdDic
}