apache/cordova-ios

document.cookie non functional in ios 6.3.0

Sathyavathi2018 opened this issue · 2 comments

We were facing CORS issue in cordova-ios@6.3.0 and added below in to resolve the same.

After adding the above preference CORS issue solved however document.cookie is always empty which is needed for our tracking purpose. If we remove the preference then cookie is retained. But in my case, we need both should work together.

Similar issue created but it's closed without any solution. For your reference: #931

This issue is a source stopper for us. Kindly guide us on how to proceed further.

Apple blocks third-party cookies by default via ITP (Intelligent Tracking Preventation). I don't think there is anyway to disable this other than the user explicitly disabling it via their settings. This applies to the WKWebView/Safari since iOS 14 and MacOS Big Sur.

other than the user explicitly disabling it via their settings.

On this, by default iOS also hides the ability for users to disable ITP for your app. NSCrossWebsiteTrackingUsageDescription needs to be set in the app's Info.plist file with a non-empty string value (as far as I can tell, the justification string isn't actually used anywheres in the UI). In the app settings, it will enable the ability to allow cross-website tracking: https://i.stack.imgur.com/O0mCY.png Again by default, the option will be disabled. Your users will need to explicitly enable it by navigating to Settings -> Your App -> Toggling on Allow Cross-Website Tracking

I don't believe Cordova has any flag to enable this for you, but you should be able to add it yourself via config-file directive.

Untested example below

<config-file target="*-Info.plist" parent="NSCrossWebsiteTrackingUsageDescription">
    <string>This allows personalized ads or whatever</string>
</config-file>

I personally don't use cookies in my tech stack, but this is my best guess of what you're running into.

Keep in mind, Apple is intentionally making it difficult for apps to track users. They market themselves as a privacy-focused company.

Let me know if enabling cross site tracking solves your cookie issue. If it doesn't please provide more information on what you're attempting to do, along with the expected/actual results. Also include on how the cookies are being set, preferably as shown in the HTTP header.

@breautek : Thanks for the detailed response. Unfortunately, we can't force user to enable the settings. So, we can close this ticket.