File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
onesignal/src/main/java/com/onesignal
unittest/src/test/java/com/test/onesignal Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -894,6 +894,14 @@ public static void setRequiresUserPrivacyConsent(boolean required) {
894
894
requiresUserPrivacyConsent = required ;
895
895
}
896
896
897
+
898
+ /**
899
+ * Indicates if the SDK is still waiting for the user to provide consent
900
+ */
901
+ public static boolean requiresUserPrivacyConsent () {
902
+ return requiresUserPrivacyConsent && !userProvidedPrivacyConsent ();
903
+ }
904
+
897
905
static boolean shouldLogUserPrivacyConsentErrorMessageForMethodName (String methodName ) {
898
906
if (requiresUserPrivacyConsent && !userProvidedPrivacyConsent ()) {
899
907
if (methodName != null )
Original file line number Diff line number Diff line change @@ -2237,6 +2237,19 @@ public void onFailure(JSONObject response) {
2237
2237
postNotificationSuccess = postNotificationFailure = null ;
2238
2238
}
2239
2239
2240
+ @ Test
2241
+ public void shouldReturnCorrectConsentRequiredStatus () throws Exception {
2242
+ OneSignal .setRequiresUserPrivacyConsent (true );
2243
+
2244
+ OneSignalInit ();
2245
+
2246
+ assertTrue (OneSignal .requiresUserPrivacyConsent ());
2247
+
2248
+ OneSignal .provideUserConsent (true );
2249
+
2250
+ assertFalse (OneSignal .requiresUserPrivacyConsent ());
2251
+ }
2252
+
2240
2253
/*
2241
2254
// Can't get test to work from a app flow due to the main thread being locked one way or another in a robolectric env.
2242
2255
// Running ActivityLifecycleListener.focusHandlerThread...advanceToNextPostedRunnable waits on the main thread.
You can’t perform that action at this time.
0 commit comments