Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disableGMSMissingPrompt public method #1332

Merged
merged 2 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ private static boolean isGooglePlayStoreInstalled() {
}

static void showUpdateGPSDialog() {
if (!OSUtils.isAndroidDeviceType() || !isGooglePlayStoreInstalled())
if (!OSUtils.isAndroidDeviceType())
return;

if (!isGooglePlayStoreInstalled() || OneSignal.getDisableGMSMissingPrompt())
return;

boolean userSelectedSkip =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ void saveRemoteParams(OneSignalRemoteParams.Params remoteParams,
logger.debug("OneSignal saveInfluenceParams: " + remoteParams.influenceParams.toString());
trackerFactory.saveInfluenceParams(remoteParams.influenceParams);

saveGMSMissingPromptDisable(remoteParams.disableGMSMissingPrompt);
if (remoteParams.disableGMSMissingPrompt != null)
saveGMSMissingPromptDisable(remoteParams.disableGMSMissingPrompt);
if (remoteParams.unsubscribeWhenNotificationsDisabled != null)
saveUnsubscribeWhenNotificationsAreDisabled(remoteParams.unsubscribeWhenNotificationsDisabled);
if (remoteParams.locationShared != null)
Expand All @@ -64,6 +65,10 @@ OneSignalRemoteParams.Params getRemoteParams() {
return remoteParams;
}

boolean hasDisableGMSMissingPromptKey() {
return remoteParams != null && remoteParams.disableGMSMissingPrompt != null;
}

boolean hasLocationKey() {
return remoteParams != null && remoteParams.locationShared != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class OSTaskRemoteController extends OSTaskController {
static final String SEND_TAG = "sendTag()";
static final String SEND_TAGS = "sendTags()";
static final String SET_LOCATION_SHARED = "setLocationShared()";
static final String SET_DISABLE_GMS_MISSING_PROMPT = "setDisableGMSMissingPrompt()";
static final String SET_REQUIRES_USER_PRIVACY_CONSENT = "setRequiresUserPrivacyConsent()";
static final String UNSUBSCRIBE_WHEN_NOTIFICATION_ARE_DISABLED = "unsubscribeWhenNotificationsAreDisabled()";
static final String HANDLE_NOTIFICATION_OPEN = "handleNotificationOpen()";
Expand All @@ -44,6 +45,7 @@ class OSTaskRemoteController extends OSTaskController {
SEND_TAG,
SEND_TAGS,
SET_LOCATION_SHARED,
SET_DISABLE_GMS_MISSING_PROMPT,
SET_REQUIRES_USER_PRIVACY_CONSENT,
UNSUBSCRIBE_WHEN_NOTIFICATION_ARE_DISABLED,
HANDLE_NOTIFICATION_OPEN,
Expand Down
12 changes: 12 additions & 0 deletions OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java
Original file line number Diff line number Diff line change
Expand Up @@ -2616,6 +2616,18 @@ public void run() {
OneSignalStateSynchronizer.setSubscription(!disable);
}


/**
* This method will be replaced by remote params set
*/
public static void disableGMSMissingPrompt(final boolean promptDisable) {
// Already set by remote params
if (getRemoteParamController().hasDisableGMSMissingPromptKey())
return;

getRemoteParamController().saveGMSMissingPromptDisable(promptDisable);
}

/**
* This method will be replaced by remote params set
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static class Params {
boolean restoreTTLFilter;
boolean clearGroupOnSummaryClick;
boolean receiveReceiptEnabled;
boolean disableGMSMissingPrompt;
Boolean disableGMSMissingPrompt;
Boolean unsubscribeWhenNotificationsDisabled;
Boolean locationShared;
Boolean requiresUserPrivacyConsent;
Expand Down Expand Up @@ -182,9 +182,9 @@ static private void processJson(String json, final @NonNull Callback callBack) {
clearGroupOnSummaryClick = responseJson.optBoolean("clear_group_on_summary_click", true);
receiveReceiptEnabled = responseJson.optBoolean("receive_receipts_enable", false);

disableGMSMissingPrompt = responseJson.optBoolean(DISABLE_GMS_MISSING_PROMPT, false);
// Null assignation to avoid remote param override user configuration until backend is done
// TODO remove has check when backend has new remote params and user sets inside OneSignal.java were removed
// TODO remove the has check when backend has new remote params and sets inside OneSignal.java are removed
disableGMSMissingPrompt = !responseJson.has(DISABLE_GMS_MISSING_PROMPT) ? null : responseJson.optBoolean(DISABLE_GMS_MISSING_PROMPT, false);
unsubscribeWhenNotificationsDisabled = !responseJson.has(UNSUBSCRIBE_ON_NOTIFICATION_DISABLE) ? null : responseJson.optBoolean(UNSUBSCRIBE_ON_NOTIFICATION_DISABLE, true);
locationShared = !responseJson.has(LOCATION_SHARED) ? null : responseJson.optBoolean(LOCATION_SHARED, true);
requiresUserPrivacyConsent = !responseJson.has(REQUIRES_USER_PRIVACY_CONSENT) ? null : responseJson.optBoolean(REQUIRES_USER_PRIVACY_CONSENT, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public void registerForPush(Context context, String senderId, PushRegistrator.Re
@Implementation
public void internalRegisterForPush(String senderId) {}


public static void fireLastCallback() {
lastCallback.complete(fail ? null : regId, fail ? -7 : 1);
}
Expand Down