Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Cookies not set in iOS Simulator #35

Closed
mkuenz opened this issue Jan 9, 2020 · 2 comments
Closed

Cookies not set in iOS Simulator #35

mkuenz opened this issue Jan 9, 2020 · 2 comments

Comments

@mkuenz
Copy link

mkuenz commented Jan 9, 2020

Device information:

  • Hardware: iOS Simulator
  • Operating System and Version: iPhone 11 Pro Max 13.3
  • Forge Platform version: v2.8.4

App information:

 "modules": {
    "contact": {
      "version": "2.13",
      "config": {
        "usage_description": "Allow access to your contacts in order to recommend the app."
      },
      "disabled": %disable_recommend_module%
    },
    "icons": {
      "version": "2.9",
      "config": {
        "android": {
          ...
          }
        },
        "ios": {
          ...
        }
      }
    },
    "launchimage": {
      "version": "2.13",
      "config": {
        "android": {
          ...
        },
        "ios": {
         ...
        },
        "hide-manually": true
      }
    },
    "display": {
      "version": "2.11",
      "config": {
        "statusbar": {
          "android": {
            "transparent": true
          },
          "ios": {}
        },
        "orientations": {
          "ipad": "any",
          "android": "any",
          "iphone": "portrait"
        }
      }
    },
    "file": {
      "version": "2.24",
      "config": {
        "usage_description": "Allow to upload images or videos stored on your device, e.g. for in app posts, comments or chat messages."
      },
      "disabled": false
    },
    "capture": {
      "version": "2.25",
      "config": {
        "usage_description": "Allow to upload images or videos stored on your device, e.g. for in app posts, comments or chat messages."
      }
    },
    "notification": {
      "version": "2.8",
      "config": {}
    },
    "bolts": {
      "version": "1.9.0",
      "config": {}
    },
    "sb_parse": {
      "version": "3.3.14",
      "config": {
        ...
        }
      }
    },
    "tabs": {
      "version": "3.3",
      "config": {}
    },
    "urlhandler": {
      "version": "2.2",
      "config": {
       ...
      }
    },
    "request": {
      "version": "2.11",
      "config": {}
    },
    "share": {
      "version": "1.3",
      "config": {}
    },
    "prefs": {
      "version": "2.2",
      "config": {}
    },
    "browsersettings": {
      "version": "1.6",
      "config": {
        "accept_cookies": true,
        "media_playback": {
          "inline_video": false,
          "autoplay_video": true,
          "enable_html5_audio": true,
          "enable_background_audio": false,
          "respect_playing_audio": true
        }
      }
    },
    "utils": {
      "version": "0.67",
      "config": {
        ...
      }
    },
    "platform": {
      "version": "2.3",
      "config": {}
    },
 }

To Reproduce

  1. XHR-call which sets cookie in response

Expected behaviour
Cookies are set.

Actual behaviour
Cookies are not set.

TypeError: undefined is not an object (evaluating 'window.forge._receive')

Bildschirmfoto 2020-01-09 um 14 07 19

Bildschirmfoto 2020-01-09 um 14 07 25

@antoinevg
Copy link
Contributor

antoinevg commented Jan 28, 2020

Possible duplicate of #26

@antoinevg
Copy link
Contributor

  • Confirmed as a long-standing Apple bug that has been present in WKWebView since at least iOS 10.
  • Existing workarounds did not work for JSONP calls.
  • Existing workarounds for other calls were rendered ineffective after Apple stopped including cookies in response headers.
  • There's a workaround.

1. Update platform to v2.8.6

"platform_version": "v2.8.6"

2. Prime cookie store

When your app first starts up, use the new forge.tools.setCookie() API to set a dummy cookie for the domain(s) you are going to be making calls to.

For example:

    forge.tools.setCookie("trigger.io", "/api/v1/auth/hello", "foo", "bar", function () {
        // cookie has been set and cookie store has been synchronized
        // continue with normal startup, make JSONP calls etc.
    });

This seems to "prime" the cookie store which then responds to the cookies sent by the server.

Only the first parameter, the domain, matters. You can set any value for the other parameters unless you wanted to provide a specific cookie.

It's essential that subsequent app startup happens in the completion callback as setting cookies and flushing the cookie storage is an asynchronous operation.

Only works on hardware, not on the iOS simulator.

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

No branches or pull requests

2 participants