-
-
Notifications
You must be signed in to change notification settings - Fork 19
feat(platform): consent to optional cookies through native ios framework #1845
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ | |
| <VitePwaManifest /> | ||
| <ClientOnly> | ||
| <!-- TODO: render server side too when styling is improved (https://github.com/dargmuesli/nuxt-cookie-control/discussions/228) --> | ||
| <CookieControl :locale="locale" /> | ||
| <CookieControl v-if="!isIOS" :locale="locale" /> | ||
| </ClientOnly> | ||
| <!-- <div | ||
| class="absolute inset-x-0 -top-16 -z-10 flex max-h-screen transform-gpu items-start justify-center overflow-hidden blur-3xl" | ||
|
|
@@ -61,6 +61,7 @@ const timezone = useTimezone() | |
| const localePath = useLocalePath() | ||
| const store = useStore() | ||
| const route = useRoute() | ||
| const cookieControl = useCookieControl() | ||
|
|
||
| // i18n | ||
| const { t, locale } = useI18n() | ||
|
|
@@ -128,6 +129,36 @@ watch( | |
| }, | ||
| ) | ||
|
|
||
| const handleTrackingPermissionResult = (event: Event) => { | ||
| const customEvent = event as CustomEvent<string> | ||
| if (customEvent.detail === 'authorized') { | ||
| cookieControl.cookiesEnabledIds.value = [GTAG_COOKIE_ID] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can dynamically load the full list of optional cookies, something like: const { moduleOptions } = useCookieControl()
moduleOptions.cookies.optional.map((x) => id.id)It would be best to have this utility function exported, but I don't find time to work on the cookie module currently, will maybe do this soon. |
||
| cookieControl.isConsentGiven.value = true | ||
| } | ||
| } | ||
|
|
||
| onMounted(() => { | ||
| if (import.meta.client) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| window.addEventListener( | ||
| 'tracking-permission-result', | ||
| handleTrackingPermissionResult, | ||
| ) | ||
| } | ||
| }) | ||
|
|
||
| onUnmounted(() => { | ||
| if (import.meta.client) { | ||
| window.removeEventListener( | ||
| 'tracking-permission-result', | ||
| handleTrackingPermissionResult, | ||
| ) | ||
| } | ||
| }) | ||
|
Comment on lines
+149
to
+156
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using https://vueuse.org/core/useEventListener/ would simplify the mount/unmount logic, just an idea. |
||
|
|
||
| const isIOS = computed(() => { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use |
||
| return /iPhone|iPad|iPod/i.test(navigator.userAgent) | ||
| }) | ||
|
|
||
| // initialization | ||
| defineOgImageComponent( | ||
| 'Default', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check if there is a way for the app to tell iOS to show the permission dialog again. Alternatively, we should hide the cookie button under the hamburger menu.