forked from joeferraro/react-native-cookies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (30 loc) · 1.08 KB
/
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
32
33
34
import React from 'react';
import { NativeModules, Platform } from 'react-native';
const invariant = require('invariant');
const RNCookieManagerIOS = NativeModules.RNCookieManagerIOS;
const RNCookieManagerAndroid = NativeModules.RNCookieManagerAndroid;
let CookieManager;
if (Platform.OS === 'ios') {
invariant(RNCookieManagerIOS,
'react-native-cookies: Add RNCookieMangerIOS.h and RNCookieManagerIOS.m to your Xcode project');
CookieManager = RNCookieManagerIOS;
} else if (Platform.OS === 'android') {
invariant(RNCookieManagerAndroid,
'react-native-cookies: Import libraries to android "react-native link react-native-cookies"');
CookieManager = RNCookieManagerAndroid;
} else {
invariant(CookieManager, 'react-native-cookies: Invalid platform. This library only supports Android and iOS.');
}
const functions = [
'set',
'setFromResponse',
'getFromResponse',
'get',
'getAll',
'clearAll',
'clearByName'
];
module.exports = {}
for (var i = 0; i < functions.length; i++) {
module.exports[functions[i]] = CookieManager[functions[i]];
}