UNPKG

2.37 kBMarkdownView Raw
1gekkou-react-native [![NPM version]](https://npmjs.com/package/gekkou-react-native)
2====
3A Wikia chat client for React Native. Fork of [Gekkou](https://gitlab.com/tsuki-studios/gekkou).
4
5## Requirements
6
7- [NodeJS](https://nodejs.org/en/download/ "Latest version recommended.")
8- [React Native](https://facebook.github.io/react-native/) (Tested with version 0.52.0, it should work with other versions too).
9
10Note that this library doesn't have any native dependencies, this means you can use it with a CRNA or Expo project.
11
12---
13
14### Installation
15
16Add the package to your project:
17
18Using Yarn: `yarn add gekkou-react-native`
19Using NPM: `npm install --save gekkou-react-native`
20
21---
22
23### Differences from core [Gekkou](https://gitlab.com/tsuki-studios/gekkou)
24
25* Replaced the `request` module with the React Native `fetch` API.
26* The way you log in has changed a bit. In core Gekkou, you use `new Client('username', 'password').` Here you can log in two ways:
27
28Logging in with a password
29----
30```js
31global.client = new Client({
32 username: 'Wikia username',
33 password: 'Wikia password'
34});
35 ```
36
37Logging in with an access_token
38----
39This is specially useful if you, for example, ask for the user's credentials on a login screen and validate them there. This way, if you save the access token returned by `https://services.wikia.com/auth/token`, you can use it to log in and avoid checking the credentials twice. This translates in less network requests, and a faster application.
40
41```js
42global.client = new Client({
43 username: 'Wikia username',
44 token: 'access token'
45});
46 ```
47
48
49### Example: Ping Pong
50
51```js
52import React from 'react';
53import { Text, View } from 'react-native';
54import { Client } from 'gekkou-react-native';
55
56export default class GekkouExample extends React.Component {
57
58 componentDidMount() {
59 global.client = new Client({
60 username: 'Wikia username',
61 password: 'Wikia password'
62 });
63
64 client.on('ready', () => {
65 console.log('client ready!');
66 });
67
68 client.on('messageCreate', (msg) => {
69 console.log(`[${msg.author.username}]: ${msg.content}`);
70 });
71
72 client.connect('your-wiki-domain');
73 }
74
75}
76```
77
78More examples can be found in the [examples folder](/examples).
79
80[NPM version]: https://img.shields.io/npm/v/gekkou-react-native.svg?style=flat-square
\No newline at end of file