A simple plugin that allows using Neura for React Native.
- react_native_sample_app >= 0.1.0 supports react-native >= 0.52.0 and react == 16.0.0
Follow the instructions to install the SDK for
Comming soon...
npm i --save react-native-neura
ORyarn add react-native-neura
- In Xcode:
- Create a new group NeuraRN inside Libraries catalog.
- drag and drop into NeuraRN group:
*
node_modules/react-native-neura/ios/NeuraSDKManager/NeuraSDKManager.m
*node_modules/react-native-neura/ios/NeuraSDKManager/NeuraSDKManager.h
npm i --save react_native_sample_app
ORyarn add react_native_sample_app
react-native link react_native_sample_app
- Connect Firebase (for push notifications)
- open AndroidStudio
Open an existing Android Studio project
- select ${projectRoot}/android
- Click
Tools > Firebase
to open theAssistant window
- Click
Cloud messaging
- Click
Connect to Firebase
- Create new or select existed firebase project
- Click
Add FCM to your app
- Accept Changes
- open file
android/app/build.gradle
and update dependencies:
...
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
...
targetSdkVersion 24
...
}
...
dependencies {
...
compile "com.android.support:appcompat-v7:23.4.0"
...
**4. Handling push notifications:
- You should install
react-native-fcm
- Add handler of neura events:
Neura.notificationHandler(notification.data)
*** Android version have to be initialized (call init
method) before using
Methods:
- (Android only)
init
:({ appUid: string, secret: string }) => void authenticate
:() =>Promise<string | Error>
isAuthenticated
: () =>Promise<boolean>
getUserAccessToken
: () =>Promise<?string>
getUserId
: () =>Promise<?string>
notificationHandler
: (neuraNotificationData) =>Promise<neuraEvent | Error>
Example:
import Neura from 'react_native_sample_app'
...
try {
//Just for android
Neura.init()
const isAuth = await Neura.isAuthenticated()
if (!isAuth) {
const token = await Neura.authenticate()
}
} catch (error) {
console.log(error)
}
...