Skip to content

Commit

Permalink
Merge pull request #8 from shortcut/support_android_12_cookies
Browse files Browse the repository at this point in the history
Support android 12 cookies
  • Loading branch information
Rasoul Miri committed Jun 14, 2023
2 parents ed3af22 + 8bc8768 commit b83beda
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

version = "4.0.1"
version = "4.0.2"

android {
compileSdkVersion 31
compileSdkVersion 33
defaultConfig {
applicationId "se.kantarsifo.mobileanalytics.sampleapp"
minSdkVersion 16
targetSdkVersion 30
targetSdkVersion 33
versionCode 1
versionName version
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
tools:targetApi="m">

<activity
android:exported="true"
android:name=".InitializationActivity"
android:windowSoftInputMode="stateHidden">

Expand Down
6 changes: 3 additions & 3 deletions libmobiletagging/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ apply plugin: 'com.github.dcendents.android-maven'

group='myGroups'

version = "4.1.2"
version = "4.2.0"


android {
compileSdkVersion 30
compileSdkVersion 33
defaultConfig {
minSdkVersion 14
targetSdkVersion 30
targetSdkVersion 33
versionCode 1
versionName version
publishNonDefault true
Expand Down
6 changes: 5 additions & 1 deletion libmobiletagging/release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ using Kantar Sifo’s services. The SDK zip file contains three folders:

RELEASE NOTES:

v4.2.0 2023-06-14

- Bug fix Android 12 for secure cookies

v4.1.2 2022-03-17

- Trusted Web Activity feature to open web activity in a secure way
- Trusted Web Activity feature to open web activity in a secure way

v4.1.1 2021-09-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ internal object CookieHandler {
this.path = path
this.domain = domain
this.maxAge = CookieHandler.getMaxAge()
this.secure = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ object SifoCookieManager {
}
val cookies = cookieManager.cookieStore.cookies
for (cookie in cookies) {
val cookieString = cookie.name + "=" + cookie.value + "; Domain=" + cookie.domain
Log.e("cookieString",cookieString)
android.webkit.CookieManager.getInstance().setCookie(cookie.domain, cookieString)
val cookieString =
cookie.name + "=" + cookie.value + "; Domain=" + cookie.domain + "; SameSite=None; path=/; secure; HttpOnly"
Log.e("cookieString", cookieString)

var newDomain = cookie.domain.trim()
if (newDomain.startsWith(".")) {
newDomain = newDomain.replaceFirst(".", "")
}
newDomain = "https://$newDomain"
android.webkit.CookieManager.getInstance()
.setCookie(newDomain, cookieString)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal class TSMobileAnalyticsBackend : TSMobileAnalytics {
}
val sdkVersion = BuildConfig.VERSION_NAME
val appVersion = activity.getApplicationVersion()
val cookieValue = "trackPanelistOnly=$onlyPanelist&isWebViewBased=$isWebBased&sdkVersion=$sdkVersion&appVersion=$appVersion"
val cookieValue = "trackPanelistOnly=$onlyPanelist&isWebViewBased=$isWebBased&sdkVersion=$sdkVersion&appVersion=$appVersion; SameSite=None; secure; Httponly"
val metaCookie = CookieHandler.createHttpCookie(TagStringsAndValues.SIFO_META_COOKIE_NAME, cookieValue)
CookieHandler.setupPanelistCookies(listOf(metaCookie))
if (paramsAreValid(cpID, applicationName)) {
Expand Down

0 comments on commit b83beda

Please sign in to comment.