Enable cookies in your ionic app

Go to

/node-v0.10.29/ionicnew/platforms/android/src/com/ionicframework/< you package name>

then open CordovaApp.java

insert below line of code:

CookieManager.setAcceptFileSchemeCookies(true);      


in ​onCreate() method like:

​super.onCreate(
savedInstanceState);
super.init();
​​
CookieManager.setAcceptFileSchemeCookies(true);       
// Set by <content src="index.html" /> in config.xml
super.setIntegerProperty("splashscreen", R.drawable.screen);
super.loadUrl(Config.getStartUrl());
 
and import following package
 
​import android.webkit.CookieManager;



12 comments:

  1. Excellent information with unique content and it is very useful to know about the information based on blogs.this is valuable information for learners.thanks
    Angularjs Training In Hyderabad

    ReplyDelete
  2. dont work when app run in device

    ReplyDelete
  3. You're a genius!!!
    Thanks You so so so much!

    I followed your steps and It works very good!
    The only comment is that I found a file called MainActivity.java, not CordovaApp.java

    So, It´s my final code:

    import android.os.Bundle;
    import android.webkit.CookieManager;
    import org.apache.cordova.*;

    public class MainActivity extends CordovaActivity
    {
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    // Set by in config.xml
    CookieManager.setAcceptFileSchemeCookies(true);
    loadUrl(launchUrl);
    }
    }

    Thanks You again!
    Best regards, HernĂ¡n!

    ReplyDelete
  4. how to check if cookies received?

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete