Giter Site home page Giter Site logo

react-native-cookies's Introduction

react-native-cookies

Cookie manager for react native.

npm version npm downloads GitHub license

This project has moved

This project has been moved to the React Native Community.

Installation

yarn add react-native-cookies

Linking

Automatic (recommended)

react-native link react-native-cookies

Manual

If automatic linking does not work, you can manually link this library by following the instructions below:

iOS
  1. Open your project in Xcode, right click on Libraries and click Add Files to "Your Project Name" Look under node_modules/react-native-cookies/ios and add RNCookieManagerIOS.xcodeproj.
  2. Add libRNCookieManagerIOS.a to `Build Phases -> Link Binary With Libraries.
  3. Clean and rebuild your project
Android

Run react-native link to link the react-native-cookies library.

Or if you have trouble, make the following additions to the given files manually:

android/settings.gradle

include ':react-native-cookies'
project(':react-native-cookies').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cookies/android')

android/app/build.gradle

dependencies {
   ...
   compile project(':react-native-cookies')
}

MainApplication.java

On top, where imports are:

import com.psykar.cookiemanager.CookieManagerPackage;

Add the CookieManagerPackage class to your list of exported packages.

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.asList(
            new MainReactPackage(),
            new CookieManagerPackage()
    );
}

Usage

import CookieManager from 'react-native-cookies';

// set a cookie (IOS ONLY)
CookieManager.set({
  name: 'myCookie',
  value: 'myValue',
  domain: 'some domain',
  origin: 'some origin',
  path: '/',
  version: '1',
  expiration: '2015-05-30T12:30:00.00-05:00'
}).then((res) => {
  console.log('CookieManager.set =>', res);
});

// Set cookies from a response header
// This allows you to put the full string provided by a server's Set-Cookie 
// response header directly into the cookie store.
CookieManager.setFromResponse(
  'http://example.com', 
  'user_session=abcdefg; path=/; expires=Thu, 1 Jan 2030 00:00:00 -0000; secure; HttpOnly')
    .then((res) => {
      // `res` will be true or false depending on success.
      console.log('CookieManager.setFromResponse =>', res);
    });

// Get cookies as a request header string
CookieManager.get('http://example.com')
  .then((res) => {
    console.log('CookieManager.get =>', res); // => 'user_session=abcdefg; path=/;'
  });

// list cookies (IOS ONLY)
CookieManager.getAll()
  .then((res) => {
    console.log('CookieManager.getAll =>', res);
  });

// clear cookies
CookieManager.clearAll()
  .then((res) => {
    console.log('CookieManager.clearAll =>', res);
  });

// clear a specific cookie by its name (IOS ONLY)
CookieManager.clearByName('cookie_name')
  .then((res) => {
    console.log('CookieManager.clearByName =>', res);
  });

WebKit-Support (iOS only)

React Native comes with a WebView component, which uses UIWebView on iOS. Introduced in iOS 8 Apple implemented the WebKit-Support with all the performance boost.

To use this it's required to use a special implementation of the WebView component (e.g. react-native-wkwebview).

This special implementation of the WebView component stores the cookies not in NSHTTPCookieStorage anymore. The new cookie-storage is WKHTTPCookieStore and implementes a differnt interface.

To use this CookieManager with WebKit-Support we extended the interface with the attribute useWebKit (a boolean value, default: FASLE) for the following methods:

Method WebKit-Support Method-Signature
getAll Yes CookieManager.getAll(useWebKit:boolean)
clearAll Yes CookieManager.clearAll(useWebKit:boolean)
get Yes CookieManager.get(url:string, useWebKit:boolean)
set Yes CookieManager.set(cookie:object, useWebKit:boolean)
Usage
import CookieManager from 'react-native-cookies';

const useWebKit = true;

// list cookies (IOS ONLY)
CookieManager.getAll(useWebKit)
	.then((res) => {
		console.log('CookieManager.getAll from webkit-view =>', res);
	});

// clear cookies
CookieManager.clearAll(useWebKit)
	.then((res) => {
		console.log('CookieManager.clearAll from webkit-view =>', res);
	});

// Get cookies as a request header string
CookieManager.get('http://example.com', useWebKit)
	.then((res) => {
		console.log('CookieManager.get from webkit-view =>', res);
		// => 'user_session=abcdefg; path=/;'
	});

// set a cookie (IOS ONLY)
const newCookie: = {
	name: 'myCookie',
	value: 'myValue',
	domain: 'some domain',
	origin: 'some origin',
	path: '/',
	version: '1',
	expiration: '2015-05-30T12:30:00.00-05:00'
};

CookieManager.set(newCookie, useWebKit)
	.then((res) => {
		console.log('CookieManager.set from webkit-view =>', res);
	});

TODO

  • Proper getAll dictionary by domain
  • Proper error handling
  • Anything else?

PR's welcome!

react-native-cookies's People

Contributors

7ynk3r avatar allenzerg001 avatar amilcar-andrade avatar filipposarzana avatar foloinfo avatar iamsoorena avatar iday avatar joeferraro avatar kacperkozak avatar kevinresol avatar marcshilling avatar mkonicek avatar mqp avatar praveenperera avatar psykar avatar ptraeg avatar pushrax avatar rmevans9 avatar sdg9 avatar shenjiayu avatar sveinfid avatar tscharke avatar ubermenschjo avatar wschurman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-cookies's Issues

Perspicacity and initial thanks

Thanks for getting the ball rolling on this little project! I've been researching for a few days now on how to handle session authentication cookies for a react-native app and truly appreciate you initiating under a pragmatic and common sense name.

Newbs like me will no doubt stumble their way to your doorstep here while trying to grok this awesome new framework.

Molte grazie e buona fortuna!

[Android] setFromResponse res in callback null, cookie still set successfully

As said in the title, the result variable passed to callback has value of null, yet everything still seems to work fine, with subsequent requests sending the cookie to the server (and I'm using xhr and setting the cookie for a different domain, so this should not be caused by the automatic cookie management in fetch).

So, this is not really a problem, just a strange behaviour / mistake in readme which says it should return 'true' ?

I'm using React Native v0.31 and Android 6 (api 23)

Get/Delete a single cookie

Hi,
Any chance add the ability to get/delete a single cookie? Right now it's either getAll or deleteAll.

Thanks a bunch!

Could not invoke RNCookieManagerAndroid.get

Getting the issue "Could not invoke RNCookieManagerAndroid.get" when trying to run this code:

getCookies: function(){
CookieManager.get(HOME_URL, (err,cookie) => {
//FIXME TODO: use config for cookie name
if (cookie && cookie.indexOf('RMSessionAuth') != -1) {
console.log(cookie);
}
else {
console.log("no cookie!");
}

});

},

I've downloaded the packages as instructed, and have also double checked the gradle and activity files to ensure that everything was setup properly. Running on a Nexus 5x, running RN version 0.20.0. Going to try updating my RN version, but just wanted to see if there could be another possible problem?

NSURLConnection is deprecated

This library uses NSURLConnection in RNCookieManagerIOS.m which has been deprecated since iOS 9.0 in favor of NSURLSession. This causes a build warning when building the project in Xcode 8.3.3.

Cannot read cookies set in react-native from rails server

I have asked the following question on stack overflow with no answer, so am asking here.
I am using react-native-cookies. I can use the getAll method to read cookies that have been previously set on the server side. In react native I can use the set command to set a cookie called 'myCookie', and I can read it using the getAll command. However, I cannot read a cookie on the server side that has been set by the react-native app.

The react-native code which is in index.ios.js

var CookieManager = require('react-native-cookies')
  componentWillMount () {
    CookieManager.set({
      name: 'myCookie',
      value: 'myValue',
      domain: 'ios app',
      origin: 'some origin',
      path: '/',
      version: '1',
      expiration: '2017-05-30T12:30:00.00-05:00'
    }, (err, res) => {
      console.log('cookie set!');
      console.log(err);
      console.log(res);
      console.log('my output');
    });
    CookieManager.getAll((cookie) => {
      let isAuthenticated;
      if (cookie && cookie.remember_token) {
        isAuthenticated = true;
      }
      else {
        isAuthenticated = false;
      }

      this.setState({
        loggedIn: isAuthenticated
      });
      console.log('GM:cookie remember isAuthenticated', cookie.remember_token, isAuthenticated,this.state.title,'myCookie',cookie.myCookie)
    });
  },

The output from the last console log message is

GM:cookie remember isAuthenticated Object {domain: "localhost", value: "BAhbB2kHSSJFZmM3NDVkNTEwZTBkYTViZjU4NTJhOGQyZDNlMz…wY6BkVU--5888c15b42c6bdf3ca34c89f6554d2455d48c46b", name: "remember_token", path: "/"} true Sign In myCookie Object {domain: "ios app", value: "myValue", name: "myCookie", path: "/"}

showing that the myCookie object is being set and that the app is able to recover the remember_token set by the rails server.

The above code is executed at start up of the ios app. The ios app then opens a webview component that calls the new method in the sessions controller of a ruby on rails web app. In the rails sessions controller, I find that cookie['myCookie'] is nil. Why is the cookie being set in a way that I cannot access it from the rails app?

Someone has suggested dropping the optional keys like domain and origin, but react-native-cookie appears to require all these keys. I have also tried setting the domain to the correct domain name and that does not help either.

how can i get the cookies header string?

your framework is very good ,thanks
But I find that using function "CookieManager.get(url, (err, res) => { }" i get the local cookie and it is in json format.
but i need the cookies header for another request ,it is like "aaa=xxxx;bbb=yyyy;ccc=zzzz",how can i get this ?

ok i know . i read your code (iOS) , i find i can use this function to get it ,and the string is in header["Cookie"]

RCT_EXPORT_METHOD(getHeader:(NSURL *)url callback:(RCTResponseSenderBlock)callback) {
NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:url];
NSDictionary *header = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies];
callback(@[[NSNull null], header]);
}

Closing the app before sync in Android

1.-Clear all the cookies.
2.-Immediately (before the cookie manager has synced), close the app.
3.-Next time you open the app, the cookie is still there

This is probably an issue with the underlying react-native component. See the comment in

https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java#L33

Would you consider something like

    @ReactMethod
    public void clearAndPersist() {
        this.cookieHandler.destroy();
    }

Android Compilation: package im.shimo.react.cookie does not exist

I get the following error when trying to run react-native run-android, iOS seems to work fine.

error: package im.shimo.react.cookie does not exist
import im.shimo.react.cookie.CookieManagerPackage;

error: cannot find symbol
            new CookieManagerPackage()
                ^
  symbol: class CookieManagerPackage
2 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

New release?

Last release was done in Aug. 2015 (0.0.3).
package.json is at 2.0.0

Can we expect a new release soon?

Android Support

I want to manage cookie in react native.
So I found this modules, but this is not working in android.

Would you mind to make another version that supports android platform?

Thanks.

clear Cookie by name

I would like to be able to clear a cookie by name. clearAll is too broad for me. Is this possible?

[Android] CookieManagerPackage.java:27: error: method does not override or implement a method from a supertype

Error occurs when I run react-native run-android
full error:

/Users/../../../../../node_modules/react-native-cookies/android/src/main/java/com/psykar/cookiemanager/CookieManagerPackage.java:27: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: /Users/../../../../../node_modules/react-native-cookies/android/src/main/java/com/psykar/cookiemanager/CookieManagerModule.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
:react-native-cookies:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-cookies:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

I believe this has something to do with updating to version 0.48.0-rc.0 of react-native.
I don't have this problem when running 0.46.0. I'm also running version 16.0.0-alpha.12 of react.

[Question] Can it read HttpOnly cookies?

I'm asking because I tried (without this library) to get an HttpOnly cookie injecting "window.postMessage(document.cookie)" in the injectedJavaScript attribute of a website loaded in a WebView and I got back all the cookies except the ones with HttpOnly set to true.

Thanks!

setFromResponse method is unresolved function

Hi, i have a little problem because i would like to set a Cookie manually but the method used for that is not detected :

CookieManager.setFromResponse(URL, 'basic=' + Basic + 'path=/; expires=Thu, 1 Jan 2030 00:00:00 -0000;');

But all the others functions are detected and fonctionnal. Does anyone have a solution? Thanks

RNCookieManagerIOS. was called with 2 arguments but expects 1 arguments.

I used RN 0.44 before, the react-native-cookies works.
Now I update RN to 0.47, and got the following error:

RNCookieManagerIOS. was called with 2 arguments but expects 1 arguments.
If you haven't changed this method your self, this usually means that your version of the native code and JavaScript code are out of sync. Updating both should make this error go away.

On Android platform, I got this error:

RNCookieManagerAndroid.get got 4 arguments, expected 3.

My code:
CookieManager.get(this.config.urlPrefix, (err, res) => {

Help is wanted.

Using promise instead of callback

Is it possible to return a promise from all function instead of callback functions. I'm a little new to javascript and use es7 to code with react-native. I would really like to know how to send promise object from native code or is it not possible.

Getting an error on `CookieManager`’s `setFromResponse` function

Hi!

When trying to use the CookieManager’s setFromResponse function the iOS simulator, while passing the following values: https://app.hibob.com, user_session=abcdefg; Max-Age=7200; Expires=Fri, 25 Aug 2017 09:34:22 GMT; Path=/; Domain=hibob.com; Secure; HTTPOnly I get the error:

JSON value of type NSString can not be converted to NSDictionary

What am I doing wrong? I mean, I understand the error, but in the example it seems a string, which is also not convertible to JSON, is passed. I was looking for the API — along with the expected types — but was not able to find it.

I’d love for some help...

Thanks!

Change argument name to be descriptive of return value

This line, as well as the documentation, seems to suggest that the err argument to the callback for getAll will be something like an error message, but here the argument is the list of cookies. Please change the naming so it's clearer how to get the cookies from the call. Thanks!

PS: If need be, I can make a PR, just say the words :)

rnpm link

It's not really nice to have to manually add this to the project every time we upgrade. Could it be made to support rnpm link?

Suggested improvements

  • Use promises instead of callbacks
  • Simplify api to match js-cookie--just need get, set, and remove; don't wanna deal with cookie strings

'Invariant Violation' exception when running tests

I'm running into an issue while running my test suite. I get an 'Invariant Violation' exception on a line that does require('react-native-cookies').

Here's my stacktrace.

/Users/tablexi/Code/Project/node_modules/invariant/invariant.js:49
    throw error;
    ^

Invariant Violation: Add RNCookieMangerIOS.h and RNCookieManagerIOS.m to your Xcode project
    at invariant (/Users/tablexi/Code/Project/node_modules/invariant/invariant.js:42:15)
    at Object.<anonymous> (/Users/tablexi/Code/Project/node_modules/react-native-cookies/index.js:10:5)
    at Module._compile (module.js:413:34)
    at Module._extensions..js (module.js:422:10)
    at require.extensions.(anonymous function) (/Users/tablexi/Code/Project/node_modules/babel-core/node_modules/babel-register/lib/node.js:134:7)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/tablexi/Code/Project/node_modules/babel-register/lib/node.js:138:7)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at getCookieManager (UserSessionRequest.js:9:21)
    at new UserSessionRequest (UserSessionRequest.js:14:59)
    at Object.<anonymous> (Logout.js:43:38)
    at Module._compile (module.js:413:34)
    at loader (/Users/tablexi/Code/Project/node_modules/babel-register/lib/node.js:130:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/tablexi/Code/Project/node_modules/babel-register/lib/node.js:140:7)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (Dashboard.js:8:1)
    at Module._compile (module.js:413:34)
    at loader (/Users/tablexi/Code/Project/node_modules/babel-register/lib/node.js:130:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/tablexi/Code/Project/node_modules/babel-register/lib/node.js:140:7)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (Dashboard.test.js:3:1)
    at Module._compile (module.js:413:34)
    at loader (/Users/tablexi/Code/Project/node_modules/babel-register/lib/node.js:130:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/tablexi/Code/Project/node_modules/babel-register/lib/node.js:140:7)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at /Users/tablexi/Code/Project/node_modules/mocha/lib/mocha.js:219:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/tablexi/Code/Project/node_modules/mocha/lib/mocha.js:216:14)
    at Mocha.run (/Users/tablexi/Code/Project/node_modules/mocha/lib/mocha.js:468:10)
    at Object.<anonymous> (/Users/tablexi/Code/Project/node_modules/mocha/bin/_mocha:403:18)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:141:18)
    at node.js:933:3
npm ERR! Test failed.  See above for more details.

And here's my package.json

{
  "name": "ProjectReactNative",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "lint": "eslint '{app,test}/**/*.js' --cache --fix",
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "mocha"
  },
  "dependencies": {
    "react-native": "^0.21.0",
    "react-native-cookies": "0.0.5",
    "react-native-radio-buttons": "^0.9.1",
    "react-native-scrollable-tab-view": "^0.4.0"
  },
  "devDependencies": {
    "babel": "^6.3.26",
    "babel-core": "^6.7.2",
    "babel-eslint": "^6.0.0-beta.5",
    "babel-jest": "^6.0.1",
    "babel-plugin-syntax-async-functions": "^6.5.0",
    "babel-plugin-syntax-class-properties": "^6.5.0",
    "babel-plugin-syntax-trailing-function-commas": "^6.5.0",
    "babel-plugin-transform-class-properties": "^6.6.0",
    "babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
    "babel-plugin-transform-es2015-block-scoping": "^6.7.1",
    "babel-plugin-transform-es2015-classes": "^6.6.5",
    "babel-plugin-transform-es2015-computed-properties": "^6.6.5",
    "babel-plugin-transform-es2015-constants": "^6.1.4",
    "babel-plugin-transform-es2015-destructuring": "^6.6.5",
    "babel-plugin-transform-es2015-for-of": "^6.6.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.7.0",
    "babel-plugin-transform-es2015-parameters": "^6.7.0",
    "babel-plugin-transform-es2015-shorthand-properties": "^6.5.0",
    "babel-plugin-transform-es2015-spread": "^6.6.5",
    "babel-plugin-transform-es2015-template-literals": "^6.6.5",
    "babel-plugin-transform-flow-strip-types": "^6.7.0",
    "babel-plugin-transform-object-assign": "^6.5.0",
    "babel-plugin-transform-object-rest-spread": "^6.6.5",
    "babel-plugin-transform-react-display-name": "^6.5.0",
    "babel-plugin-transform-react-jsx": "^6.6.5",
    "babel-plugin-transform-regenerator": "^6.6.5",
    "babel-preset-airbnb": "^1.0.1",
    "chai": "^3.4.1",
    "chai-as-promised": "^5.2.0",
    "enzyme": "^2.2.0",
    "eslint": "~2.2.0",
    "eslint-config-standard": "^5.1.0",
    "eslint-plugin-promise": "^1.1.0",
    "eslint-plugin-react": "^4.2.1",
    "eslint-plugin-standard": "^1.3.2",
    "mocha": "^2.3.4",
    "mockery": "^1.4.1",
    "react-addons-test-utils": "^0.14.7",
    "react-dom": "^0.14.7",
    "react-native-mock": "^0.0.6",
    "sinon": "^1.17.3"
  }
}

Add RNCookieManagerIOS.h and RNCookieManagerIOS.m to your Xcode project

So I did the following:

  • npm install react-native-cookies
  • rnpm link react-native-cookies

Alls good here, no errors. Then I added the following line to my index file:

import CookieManager from 'react-native-cookies';

and restarted my simulator... that's where I get this error

"Add RNCookieManagerIOS.h and RNCookieManagerIOS.m to your Xcode project"

It works fine, when the simulator is started from Xcode.

Could not resolve all dependencies for configuration ':react-native-cookies:_debugCompile'

A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-cookies'.
   > Could not resolve all dependencies for configuration ':react-native-cookies:_debugCompile'.
      > Could not find com.facebook.react:react-native:<your_version_here>.
        Searched in the following locations:
            file:/Users/developer/.m2/repository/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.pom
            file:/Users/developer/.m2/repository/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.jar
            https://jcenter.bintray.com/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.pom
            https://jcenter.bintray.com/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.jar
            file:/Users/developer/Development/App/node_modules/react-native/android/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.pom
            file:/Users/developer/Development/App/node_modules/react-native/android/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.jar
            https://repo1.maven.org/maven2/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.pom
            https://repo1.maven.org/maven2/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.jar
            file:/Users/developer/Library/Android/sdk/extras/android/m2repository/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.pom
            file:/Users/developer/Library/Android/sdk/extras/android/m2repository/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.jar
            file:/Users/developer/Library/Android/sdk/extras/google/m2repository/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.pom
            file:/Users/developer/Library/Android/sdk/extras/google/m2repository/com/facebook/react/react-native/<your_version_here>/react-native-<your_version_here>.jar
        Required by:
            mobileCashier:react-native-cookies:unspecified

Migrating to RN 0.46.+

Configure project :react-native-cookies
The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead.
The getTestClassesDir() method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the getTestClassesDirs() method instead.
The ConfigurableReport.setDestination(Object) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the method ConfigurableReport.setDestination(File) instead.

Import libraries to android "rnpm link"

在windows使用react-native0.43.2开发app
按照说明操作了所有准备工作,但是在代码中引用时,报错了。
引用方式:
import {CookieManager} from 'react-native-cookies';
模拟器错误:
Import libraries to android "rnpm link"

index.android.bundle?platform=android&dev=true&hot=false&minify=false:58178:14
loadModuleImplementation
index.android.bundle?platform=android&dev=true&hot=false&minify=false:109:12
guardedLoadModule
index.android.bundle?platform=android&dev=true&hot=false&minify=false:70:36
_require
index.android.bundle?platform=android&dev=true&hot=false&minify=false:54:77

index.android.bundle?platform=android&dev=true&hot=false&minify=false:1242:34
loadModuleImplementation
index.android.bundle?platform=android&dev=true&hot=false&minify=false:109:12
guardedLoadModule
index.android.bundle?platform=android&dev=true&hot=false&minify=false:70:36
_require
index.android.bundle?platform=android&dev=true&hot=false&minify=false:54:77

index.android.bundle?platform=android&dev=true&hot=false&minify=false:1232:97
loadModuleImplementation
index.android.bundle?platform=android&dev=true&hot=false&minify=false:109:12
guardedLoadModule
index.android.bundle?platform=android&dev=true&hot=false&minify=false:63:45
_require
index.android.bundle?platform=android&dev=true&hot=false&minify=false:54:77
global code
index.android.bundle?platform=android&dev=true&hot=false&minify=false:62380:9

cmd错误:
SyntaxError: Unexpected end of JSON input
at parse ()
at process._tickCallback (internal/process/next_tick.js:109:7)
{ Error: write EPIPE
at exports._errnoException (util.js:1033:11)
at Socket._writeGeneric (net.js:727:26)
at Socket._write (net.js:746:8)
at doWrite (_stream_writable.js:329:12)
at writeOrBuffer (_stream_writable.js:315:5)
at Socket.Writable.write (_stream_writable.js:241:11)
at Socket.write (net.js:673:40)
at Socket.Writable.end (_stream_writable.js:475:10)
at Socket.end (net.js:443:31)
at Promise.resolve.then.then.then.catch.then.message (E:\workspace\NodeJsProject\react-native\react-native-navigation-example\node_modules\react-native\packager\src\Server\symbolicate\worker.js:35:33) code: 'EPIPE', errno: 'EPIPE', syscall: 'write' }

SetCookie for Android

Is this on the roadmap? Doesn't seem to work atm

Also: is there a neat way to edit cookies?

thanks

Example with fetch() login

Awesome library! This is more on the lines of a feature request:

Can you provide an example or a link using this cookie manager to pass and set cookies through fetch() to login a user? I've found documentation on the interwebs pretty lacking when it comes to that. Maybe I missed something though, still a beginner!

[iOS] Use NSHTTPCookieMaximumAge for version 1 cookies

From Apple's documentation:

NSHTTPCookieExpires

An NSDate object or NSString object specifying the expiration date for the cookie.

This cookie attribute is only used for Version 0 cookies. This cookie attribute is optional.

Available in iOS 2.0 and later.

NSHTTPCookieMaximumAge

An NSString object containing an integer value stating how long in seconds the cookie should be kept, at most.

Only valid for Version 1 cookies and later. Default is "0". This cookie attribute is optional.

Available in iOS 2.0 and later.

https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSHTTPCookie_Class/#//apple_ref/doc/constant_group/HTTP_Cookie_Attribute_Keys

Better document purpose of this library?

Hi,

This may seem crazy but I'm not sure to understand why this library should be used.

Is it possible to explain some common usecases?

The first question that comes to mind is weither or not this library can be used for cookie-based auth. Will cookies be automatically sent in every server request if I use fetch(url) for example?

Or is this library just some utility to parse cookies from response, and put them in some storage space?

Cannot read property 'getAll' of undefined

Hi,
I am faced with the same issue as this: facebook/react-native#1274

This is roughly my code:
var CookieManager = require('react-native-cookies');
CookieManager.getAll((err, res) => {
console.log('cookies!');
console.log(err);
console.log(res);
});

The cookie manager is defined, and so is the getAll method.

Someone suggested that maybe the files where not properly added to the xcode project. Do I need to "add files to.." the most top level name of the app (the one that states the sdk under it) or to the folder which has the same app name?

Thanks!

SetResponse on iOS requires NSDictionary but JS Sends String?

It appears that setResponse may be misaligned from the iOS Side to expect an NSDictionary when the documentation specifies to send a string for android. If this is the case can we either A) Line up the iOS side to accept a string and parse that into an NSDictionary for saving or B) Document the method on the iOS side as a noOP similar to what Set does on android.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.