react-native-cookies
react-native-cookies copied to clipboard
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?
Just updated to RN v0.23.1, still encountering the issue.
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.
also encountering this with RN 0.24.1
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 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 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
I guess we can close this bug
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?
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 ?
RN 0.44
v3.2.0
.get
still not work on iOS - returns empty object {}