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

Display location permission dialog only when window.geofence.initialize() is called #85

Closed
shtaif opened this issue Sep 21, 2015 · 3 comments

Comments

@shtaif
Copy link

shtaif commented Sep 21, 2015

It is quite desirable to be able to have control on when to request this permission from the user, rather than showing it as soon as the app launched for the first time.

@garrettlangley
Copy link

@shtaif did you figure out how to do this?

@shtaif
Copy link
Author

shtaif commented Oct 11, 2015

@garrettlangley
I do not know Swift lang, BUT! I managed to improvise a work around that postpones the permission dialog up until you add a region to monitor for the first time (using window.geofence.addOrUpdate()), if that helps you :)

What I did is edit the GeofencePlugin.swift file inside the plugin as follows:

  1. Find class "GeoNotificationManager".
  2. In it's "init" method you'll find the line:
    if iOS8 {
    locationManager.requestAlwaysAuthorization()
    }
    Move it into the start of the method "addOrUpdateGeoNotification", which is just the next method on this class.
  3. Make this change to be picked up by your next builds:
    Either perform the edit also in the internal copy of the GeofencePlugin.swift file in your Cordova project -> platforms -> ios -> project name -> plugins,
    or else, if possible,
    after editing the one in the standard Cordova project's "plugins" folder, do:
    "cordova platform rm ios",
    then:
    "cordova platform add ios",
    and it should be ready.

Hope my instructions are good for you :)
good luck.

@garrettlangley
Copy link

thanks @shtaif i actually did something similar wherein i commented out the request for permissions from this plugin, and am getting the permissions from window.navigator.geolocation.getCurrentPosition(watchSuccess, watchError);

@tsubik tsubik closed this as completed in e92e2e3 Oct 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants