Skip to content

Commit dee9282

Browse files
authored
Add disableGMSMissingPrompt public method (#1332)
* Add disableGMSMissingPrompt public method * Add public setter for disableGMSMissingPrompt, do not override dashboard configuration * Use param under showUpdateGPSDialog
1 parent e9208f5 commit dee9282

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/GooglePlayServicesUpgradePrompt.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ private static boolean isGooglePlayStoreInstalled() {
2828
}
2929

3030
static void showUpdateGPSDialog() {
31-
if (!OSUtils.isAndroidDeviceType() || !isGooglePlayStoreInstalled())
31+
if (!OSUtils.isAndroidDeviceType())
32+
return;
33+
34+
if (!isGooglePlayStoreInstalled() || OneSignal.getDisableGMSMissingPrompt())
3235
return;
3336

3437
boolean userSelectedSkip =

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSRemoteParamController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ void saveRemoteParams(OneSignalRemoteParams.Params remoteParams,
4747
logger.debug("OneSignal saveInfluenceParams: " + remoteParams.influenceParams.toString());
4848
trackerFactory.saveInfluenceParams(remoteParams.influenceParams);
4949

50-
saveGMSMissingPromptDisable(remoteParams.disableGMSMissingPrompt);
50+
if (remoteParams.disableGMSMissingPrompt != null)
51+
saveGMSMissingPromptDisable(remoteParams.disableGMSMissingPrompt);
5152
if (remoteParams.unsubscribeWhenNotificationsDisabled != null)
5253
saveUnsubscribeWhenNotificationsAreDisabled(remoteParams.unsubscribeWhenNotificationsDisabled);
5354
if (remoteParams.locationShared != null)
@@ -64,6 +65,10 @@ OneSignalRemoteParams.Params getRemoteParams() {
6465
return remoteParams;
6566
}
6667

68+
boolean hasDisableGMSMissingPromptKey() {
69+
return remoteParams != null && remoteParams.disableGMSMissingPrompt != null;
70+
}
71+
6772
boolean hasLocationKey() {
6873
return remoteParams != null && remoteParams.locationShared != null;
6974
}

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSTaskRemoteController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class OSTaskRemoteController extends OSTaskController {
1919
static final String SEND_TAG = "sendTag()";
2020
static final String SEND_TAGS = "sendTags()";
2121
static final String SET_LOCATION_SHARED = "setLocationShared()";
22+
static final String SET_DISABLE_GMS_MISSING_PROMPT = "setDisableGMSMissingPrompt()";
2223
static final String SET_REQUIRES_USER_PRIVACY_CONSENT = "setRequiresUserPrivacyConsent()";
2324
static final String UNSUBSCRIBE_WHEN_NOTIFICATION_ARE_DISABLED = "unsubscribeWhenNotificationsAreDisabled()";
2425
static final String HANDLE_NOTIFICATION_OPEN = "handleNotificationOpen()";
@@ -44,6 +45,7 @@ class OSTaskRemoteController extends OSTaskController {
4445
SEND_TAG,
4546
SEND_TAGS,
4647
SET_LOCATION_SHARED,
48+
SET_DISABLE_GMS_MISSING_PROMPT,
4749
SET_REQUIRES_USER_PRIVACY_CONSENT,
4850
UNSUBSCRIBE_WHEN_NOTIFICATION_ARE_DISABLED,
4951
HANDLE_NOTIFICATION_OPEN,

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,6 +2616,18 @@ public void run() {
26162616
OneSignalStateSynchronizer.setSubscription(!disable);
26172617
}
26182618

2619+
2620+
/**
2621+
* This method will be replaced by remote params set
2622+
*/
2623+
public static void disableGMSMissingPrompt(final boolean promptDisable) {
2624+
// Already set by remote params
2625+
if (getRemoteParamController().hasDisableGMSMissingPromptKey())
2626+
return;
2627+
2628+
getRemoteParamController().saveGMSMissingPromptDisable(promptDisable);
2629+
}
2630+
26192631
/**
26202632
* This method will be replaced by remote params set
26212633
*/

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignalRemoteParams.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static class Params {
8383
boolean restoreTTLFilter;
8484
boolean clearGroupOnSummaryClick;
8585
boolean receiveReceiptEnabled;
86-
boolean disableGMSMissingPrompt;
86+
Boolean disableGMSMissingPrompt;
8787
Boolean unsubscribeWhenNotificationsDisabled;
8888
Boolean locationShared;
8989
Boolean requiresUserPrivacyConsent;
@@ -182,9 +182,9 @@ static private void processJson(String json, final @NonNull Callback callBack) {
182182
clearGroupOnSummaryClick = responseJson.optBoolean("clear_group_on_summary_click", true);
183183
receiveReceiptEnabled = responseJson.optBoolean("receive_receipts_enable", false);
184184

185-
disableGMSMissingPrompt = responseJson.optBoolean(DISABLE_GMS_MISSING_PROMPT, false);
186185
// Null assignation to avoid remote param override user configuration until backend is done
187-
// TODO remove has check when backend has new remote params and user sets inside OneSignal.java were removed
186+
// TODO remove the has check when backend has new remote params and sets inside OneSignal.java are removed
187+
disableGMSMissingPrompt = !responseJson.has(DISABLE_GMS_MISSING_PROMPT) ? null : responseJson.optBoolean(DISABLE_GMS_MISSING_PROMPT, false);
188188
unsubscribeWhenNotificationsDisabled = !responseJson.has(UNSUBSCRIBE_ON_NOTIFICATION_DISABLE) ? null : responseJson.optBoolean(UNSUBSCRIBE_ON_NOTIFICATION_DISABLE, true);
189189
locationShared = !responseJson.has(LOCATION_SHARED) ? null : responseJson.optBoolean(LOCATION_SHARED, true);
190190
requiresUserPrivacyConsent = !responseJson.has(REQUIRES_USER_PRIVACY_CONSENT) ? null : responseJson.optBoolean(REQUIRES_USER_PRIVACY_CONSENT, false);

OneSignalSDK/unittest/src/test/java/com/onesignal/ShadowPushRegistratorFCM.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public void registerForPush(Context context, String senderId, PushRegistrator.Re
7474
@Implementation
7575
public void internalRegisterForPush(String senderId) {}
7676

77-
7877
public static void fireLastCallback() {
7978
lastCallback.complete(fail ? null : regId, fail ? -7 : 1);
8079
}

0 commit comments

Comments
 (0)