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

[question]: location tracking when user sets permission later #1582

Open
1 task done
stilllovinnero opened this issue Oct 4, 2023 · 1 comment
Open
1 task done

Comments

@stilllovinnero
Copy link

stilllovinnero commented Oct 4, 2023

How can we help?

I have a problem with the following use-flow:

  • On first startup of the app I ask the user for location tracking permission
  • The user denies
  • later on the user decides to allow tracking via the settings

When the user allows the tracking via settings, the location point is not send to the OneSignal Dashboard.

Is there something I have to do in my App to react to these permission changes?

Right now I try to do this when returning to the app from settings, using OneSignal.Location.setShared():

switch (Platform.OS) {
	case "ios":
		checkMultiple([
			PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
			PERMISSIONS.IOS.LOCATION_ALWAYS,
		]).then((statuses) => {
			const trackingAllowed =
				statuses[PERMISSIONS.IOS.LOCATION_WHEN_IN_USE] ===
						RESULTS.GRANTED ||
				statuses[PERMISSIONS.IOS.LOCATION_ALWAYS] === RESULTS.GRANTED;
			OneSignal.Location.setShared(trackingAllowed);
			console.log("tracking allowed", trackingAllowed);
		});
		break;
	case "android":
		checkMultiple([
			PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
			PERMISSIONS.ANDROID.ACCESS_BACKGROUND_LOCATION,
		]).then((statuses) => {
			const trackingAllowed =
				statuses[PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION] ===
					RESULTS.GRANTED ||
				statuses[PERMISSIONS.ANDROID.ACCESS_BACKGROUND_LOCATION] ===
					RESULTS.GRANTED;
			OneSignal.Location.setShared(trackingAllowed);
		});
               break;
}

Another question would be, if there is a way to get the answer of the user from OneSignal.Location.requestPermission() similar to await OneSignal.Notifications.requestPermission(fallbackToSettings: boolean)?

Code of Conduct

  • I agree to follow this project's Code of Conduct
@emawby
Copy link
Contributor

emawby commented Oct 11, 2023

@stilllovinnero Thank you for reaching out we will investigate the issue. Unfortunately there is not value returned from the requestPermission for location, but we will investigate adding that in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants