Panagiotis Triantafyllou

push fixes

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cosbeta73a'
PUBLISH_VERSION = '4.5.4-cosbeta73'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -50,6 +50,7 @@ import androidx.work.WorkManager;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;
import java.security.SecureRandom;
......@@ -60,6 +61,7 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import ly.warp.sdk.Warply;
import ly.warp.sdk.db.WarplyDBHelper;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.request.PacingCalculateRequest;
......@@ -86,7 +88,7 @@ public class WarpViewActivity extends WarpBaseActivity {
// ===========================================================
private WarpView mWarpView;
private static Handler metersHandler = new Handler();
private static Handler metersHandler;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -95,6 +97,7 @@ public class WarpViewActivity extends WarpBaseActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
metersHandler = new Handler();
WarplySessionManager.onCreateActivity(this);
initViews();
Warply.getInitializer(this).init();
......@@ -223,6 +226,22 @@ public class WarpViewActivity extends WarpBaseActivity {
// user viewed campaign through notification
if (intent.hasExtra("source") && intent.getStringExtra("source").
equalsIgnoreCase("from_notification_status")) {
JSONObject params = new JSONObject();
try {
params.putOpt("web_id", WarpUtils.getWebId(Warply.getWarplyContext()));
params.putOpt("app_uuid", WarplyProperty.getAppUuid(Warply.getWarplyContext()));
params.putOpt("api_key", WarpUtils.getApiKey(Warply.getWarplyContext()));
params.putOpt("session_uuid", sessionUUID);
params.putOpt("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token"));
params.putOpt("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token"));
params.putOpt("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id"));
params.putOpt("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret"));
} catch (JSONException e) {
e.printStackTrace();
}
WarpUtils.setWebviewParams(Warply.getWarplyContext(), params);
setUpPushEvents(sessionUUID);
}
......
......@@ -73,6 +73,7 @@ import ly.warp.sdk.io.models.PushCampaign;
import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest;
import ly.warp.sdk.io.request.CosmoteSharingRequest;
import ly.warp.sdk.io.request.WarplyConsumerRequest;
import ly.warp.sdk.io.request.WarplyEditConsumerRequest;
import ly.warp.sdk.io.request.WarplyIntegrationRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
......@@ -955,13 +956,42 @@ public class WarplyManagerHelper {
} catch (JSONException e) {
e.printStackTrace();
}
WarplyManager.editConsumer(new WarplyEditConsumerRequest()
.setHasProfileMetadata(true)
.setProfileMetadata(obj), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
WarpUtils.log("EDIT CONSUMER SUCCESS");
WarplyManager.getConsumer(new WarplyConsumerRequest(), new CallbackReceiver<Consumer>() {
@Override
public void onSuccess(Consumer result) {
WarplyManagerHelper.setConsumerInternal(result);
if (result != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata());
if (profMetadata != null && profMetadata.has("nonTelco")) {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco"));
} else {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false);
}
}
if (result != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata());
if (profMetadata != null) {
if (profMetadata.has("badge")) {
WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge"));
}
}
}
}
@Override
public void onFailure(int errorCode) {
}
});
}
@Override
......