forked from joeferraro/react-native-cookies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (28 loc) · 927 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
import React from 'react';
import {NativeModules, Platform} from 'react-native';
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',
'clearByName'
];
module.exports = {}
for (var i=0; i < functions.length; i++) {
module.exports[functions[i]] = CookieManager[functions[i]];
}