Skip to content

Commit 93d255c

Browse files
committed
Remove autoPromptLocation configuration
* Relay on promptLocation method
1 parent 1a95a64 commit 93d255c

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

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

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,9 @@ static Activity getCurrentActivity() {
295295

296296
static OSRemoteNotificationReceivedHandler remoteNotificationReceivedHandler;
297297
static OSNotificationWillShowInForegroundHandler notificationWillShowInForegroundHandler;
298-
299-
// TODO: Start of old mInitBuilder params
300-
// These should be cleaned up and managed else where maybe?
301-
// These have been ripped out of mInitBuilder since it was deleted and placed here for now
302298
static OSNotificationOpenedHandler notificationOpenedHandler;
303299
static OSInAppMessageClickHandler inAppMessageClickHandler;
304300

305-
static boolean mAutoPromptLocation;
306-
// TODO: End of old mInitBuilder params
307-
308301
// Is the init() of OneSignal SDK finished yet
309302
private static boolean initDone;
310303
static boolean isInitDone() {
@@ -375,7 +368,7 @@ static OSInAppMessageController getInAppMessageController() {
375368

376369
@NonNull private static OSUtils osUtils = new OSUtils();
377370

378-
private static boolean registerForPushFired, locationFired, promptedLocation, getTagsCall, waitingToPostStateSync, androidParamsRequestStarted;
371+
private static boolean registerForPushFired, locationFired, getTagsCall, waitingToPostStateSync, androidParamsRequestStarted;
379372

380373
private static LocationController.LocationPoint lastLocationPoint;
381374

@@ -516,23 +509,6 @@ private static class IAPUpdateJob {
516509
}
517510
private static IAPUpdateJob iapUpdateJob;
518511

519-
/**
520-
* Prompts the user for location permissions.
521-
* This allows for geotagging so you can send notifications to users based on location.
522-
* This does not accommodate any rationale-gating that is encouraged before requesting
523-
* permissions from the user.
524-
* <br/><br/>
525-
* See {@link #promptLocation()} for more details on how to manually prompt location permissions.
526-
*
527-
* @param enable If set to {@code false}, OneSignal will not prompt for location.
528-
* If set to {@code true}, OneSignal will prompt users for location permissions
529-
* when your app starts
530-
* @return the builder object you called this method on
531-
*/
532-
public static void autoPromptLocation(boolean enable) {
533-
mAutoPromptLocation = enable;
534-
}
535-
536512
/**
537513
* If notifications are disabled for your app, unsubscribe the user from OneSignal.
538514
* This will happen when your users go to <i>Settings</i> > <i>Apps</i> and turn off notifications or
@@ -876,12 +852,10 @@ public void onComplete(LocationController.LocationPoint point) {
876852
registerUser();
877853
}
878854
};
879-
boolean doPrompt = mAutoPromptLocation && !promptedLocation;
880-
// Prompted so we don't ask for permissions more than once
881-
promptedLocation = promptedLocation || mAutoPromptLocation;
882855

883-
LocationController.getLocation(appContext, doPrompt, false, locationHandler);
856+
LocationController.getLocation(appContext, false, false, locationHandler);
884857
}
858+
885859
private static PushRegistrator mPushRegistrator;
886860

887861
private static PushRegistrator getPushRegistrator() {
@@ -2424,7 +2398,6 @@ void onAnswered(OneSignal.PromptActionResult result) {
24242398
};
24252399

24262400
LocationController.getLocation(appContext, true, fallbackToSettings, locationHandler);
2427-
promptedLocation = true;
24282401
}
24292402

24302403
/**

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public void testDeviceTypeIsAmazon_withoutOneSignalInit() throws Exception {
443443
@Config(sdk = 26)
444444
public void testLocationPermissionPromptWithPrivacyConsent() throws Exception {
445445
ShadowOneSignalRestClient.setRemoteParamsRequirePrivacyConsent(true);
446-
OneSignal.autoPromptLocation(true);
446+
OneSignal.promptLocation();
447447
OneSignalInit();
448448
threadAndTaskWait();
449449

@@ -545,7 +545,6 @@ public void testAppOnFocusAfterOnSessionCallFail() throws Exception {
545545

546546
@Test
547547
public void testAppOnFocusNeededAfterOnSessionCall() throws Exception {
548-
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE);
549548
OneSignalInit();
550549
threadAndTaskWait();
551550

0 commit comments

Comments
 (0)