react-native-cookies icon indicating copy to clipboard operation
react-native-cookies copied to clipboard

Could not invoke RNCookieManagerAndroid.get

Open ssh-randy opened this issue 8 years ago • 10 comments

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?

ssh-randy avatar Apr 15 '16 05:04 ssh-randy

Just updated to RN v0.23.1, still encountering the issue.

ssh-randy avatar Apr 16 '16 04:04 ssh-randy

I hate to say it, but you're probably better off trying to downgrade your RN - I wrote the android side for 0.18 from memory, but should work with 0.19. Unfortunately I've since moved on to other projects and don't have the time to look at this in the near future.

Psykar avatar Apr 21 '16 00:04 Psykar

also encountering this with RN 0.24.1

burgalon avatar May 05 '16 18:05 burgalon

okay.. .found the reason for this. Android API is different: Use this: if(Platform.OS == 'ios') CookieManager.getAll(c) else CookieManager.get(this.props.url, c)

burgalon avatar May 08 '16 20:05 burgalon

@burgalon i'd accept a PR for this if you can confirm that fix works for Android. Thanks, I haven't had a chance to test on Android with the latest RN versions.

joeferraro avatar May 09 '16 13:05 joeferraro

@joeferraro The code above does not "fix" the issue. It just implies that the module functions are different across Android/IOS platforms, and one should should use getAll for IOS and get(url, callback) for Android. I remember some time ago, that CookieManager did spew a proper error indicating you should use get instead of getAll but now I encountered this other error Could not invoke RNCookieManagerAndroid.get

burgalon avatar May 10 '16 13:05 burgalon

I guess we can close this bug

burgalon avatar May 10 '16 13:05 burgalon

I'm a touch confused here? The readme does cover the fact that getAll is IOS only. (Android doesn't provide an API to get all cookies, you have to specify a domain) get should work on both Android and IOS though, and most use cases you will know the domain so you shouldn't need to add a Platform.OS check.

However, the report on this issue from @cabooserwar mentions that it's get that's not working, which means there might still be an issue?

Psykar avatar May 10 '16 23:05 Psykar

I am facing the same issue with React Native 0.25.1 for Android using the get(url, callback) method Is downgrading react-native the only solution? @cabooserwar @Psykar ?

prithsharma avatar Jun 16 '16 06:06 prithsharma

RN 0.44 v3.2.0 .get still not work on iOS - returns empty object {}

iegik avatar Aug 30 '17 17:08 iegik