Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>** Update 2017 **<br> A lot of changes to security mechanisms and cross-app communication were introduced to iOS in the recent years since this was first answered.</p> <p>The below code no longer works on current iOS releases since Safari no longer accepts <code>javascript:...</code> in URLs and frameworks like <code>NSURL</code> catch these and return <code>nil</code>.</p> <p>The one alternative that still works is to either host a website and have Safari open it or integrate such a HTML page in your app and run a small http server to host it on demand.</p> <p>**iOS up to 6.x **<br> Since Apple has forced the <em>sandboxing</em> on all app store applications<br> there's currently no easy way to realize your request. </p> <p>You could however open a special <a href="http://-URL" rel="nofollow noreferrer">http://-URL</a> from your application containing javascript to place a cookie:</p> <pre><code>NSString jsURL = @"javascript:function someFunction(){ /* your javascript code here */ } someFunction();void(0)"; [[UIApplication sharedApplication] openURL:[NSURL URLWithString: jsURL]]; </code></pre> <p>Using javascript in URLs has been used by different iPhone applications to cross communicate<br> with MobileSafari (for example <a href="http://www.instapaper.com" rel="nofollow noreferrer">instapaper</a>). </p> <p>Another option would be to include a static HTML page in your app or on your server and instruct MobileSafari to open it.<br> The page in turn could set the permanent cookie.</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload