forked from joeferraro/react-native-cookies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (28 loc) · 935 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var React = require('react-native');
var NativeModules = React.NativeModules;
var Platform = React.Platform;
var invariant = require('invariant');
var RNCookieManagerIOS = NativeModules.RNCookieManagerIOS;
var RNCookieManagerAndroid = NativeModules.RNCookieManagerAndroid;
var CookieManager;
if (Platform.OS === 'ios') {
invariant(RNCookieManagerIOS,
'Add RNCookieMangerIOS.h and RNCookieManagerIOS.m to your Xcode project');
CookieManager = RNCookieManagerIOS;
} else if (Platform.OS === 'android') {
invariant(RNCookieManagerAndroid, 'Import libraries to android "rnpm link"');
CookieManager = RNCookieManagerAndroid;
} else {
invariant(CookieManager, "Invalid platform");
}
var functions = [
'set',
'setFromResponse',
'get',
'getAll',
'clearAll'
];
module.exports = {}
for (var i=0; i < functions.length; i++) {
module.exports[functions[i]] = CookieManager[functions[i]];
}