The previous introduction about React-native's running Helloword level, so the simple thing is not written, after all, the official web can be found.
Reactnative Official website: https://facebook.github.io/react-native/docs/getting-started.html
Reactnative Chinese web: http://reactnative.cn/docs/0.25/getting-started.html
After that I will share some of the react-native deep pits I have encountered in my work.
About ===========================
The acquisition of client-side cookies is a big pit.
1. Use three-party
Research reactnative Source Discovery, the framework does not implement the iOS Nshttpcookiestorage API, so search all over Baidu Google and Bing, finally found a buddy wrote third-party cookies tools:
Https://github.com/joeferraro/react-native-cookies
What I need to mention here is that I need to obtain a cookie not only in the form of a dictionary, but as a cookiesheader for HTTP requests, in the form of a string, which is obtained in OC in the following way:
Nsarray *cookies =*header = [Nshttpcookie requestheaderfieldswithcookies:cookies];
But there seems to be some problem with the original author's frame, so I wrote a pull request to access my Fork's project:
Https://github.com/rayshen/react-native-cookies
2. Get the current URL
This requires a combination of the WebView control to operate.
First we need to determine the current URL, and the current URL can be obtained from the event onnavigationstatechange that the WebView control binds to:
Onnavigationstatechange={this.onnavigationstatechange.bind (This)}
Onnavigationstatechange (navstate) { console.log (navstate.url); This.cururl = Navstate.url; }
3. Obtain the URL of the cookie header:
Cookiemanager.getheader (This.cururl, (err, res) = { Console.log (' Got Cookies for URL: ' + res. Cookies); })
4. All cookies obtained from the URL
Cookiemanager.get (' http://example.com ', (err, res) = = { Console.log (res);})
React-native current URL and access to cookies