1

We are currently transpiling our android manager layer with j2objc to iOS. It seems to work very well, but now I have an issue with java.net and Cookie handling. We using an own implementation of a java.net.CookieStore for persisting Cookies

To use this CookieStore, I create a new default CookieManager, which works on Android but not on iOS:

    cookieManager = new CookieManager(new PersistentCookieStore(), CookiePolicy.ACCEPT_ALL);
    CookieHandler.setDefault(cookieManager);

I think, that the iOS implementation of HttpUrlConnection does not use the default CookieHandler.

Has anyone already experience with java.net.*, j2objc and persistent cookies?

L6Echo
  • 29
  • 7

2 Answers2

0

I think your best bet is to implement the Apache HttpClient CookieStore interface so it uses the iOS NSHTTPCookieStorage class.

tball
  • 1,984
  • 11
  • 21
  • I am not sure if I got your mind. We switched from org.apache.HttpClient to net.java.* because Apache HttpClient is deprecated for Android and net.java is available in j2objc environment. Do you mean I should implement my PersistentCookieStore (java.net.CookieStore) so, that is uses on iOS the NSHTTPCookieStorage? That make sense, but it isn't my issue. My issue is, that on iOS my CookieStore won't be addressed by HttpUrlConnection to load and save cookies (in Android it does) Or is there a possibility to use org.apache.HttpClient with j2objc? – L6Echo Feb 03 '16 at 10:28
  • 1
    Got it -- the native support for HttpUrlConnection is ignoring the Java cookie support. I filed issue 704 (https://github.com/google/j2objc/issues/704); if you subscribe to it, you'll be notified as soon as it's fixed. – tball Feb 04 '16 at 22:40
  • Wow, thank you! That was a very quick bug finding and fixing. What do you think, how long will it take for the next j2objc release? – L6Echo Feb 09 '16 at 08:38
  • Hopefully today -- we just started a release build, and will post it once it's verified (or rinse and repeat if there are issues :-). – tball Feb 09 '16 at 17:24
  • Thank you very much for your very fast support. I will test it and mark this question as answered. – L6Echo Feb 22 '16 at 13:25
0

Like @tball said, this was fixed in j2objc 1.0.1.

L6Echo
  • 29
  • 7