xpush client for React Native
##About XPUSH
% npm i https://github.com/xpush/lib-xpush-react-native.git
- Open up your project in xcode and right click the package.
- Click Add files to 'Your project name'
- Navigate to /node_modules/react-native-xpush-client/ios/XPush
- Click 'Add'
- Click your project in the navigator on the left and go to build settings
- Search for Objective-C Bridging Header
- Double click on the empty column
- Enter ../node_modules/react-native-xpush-client/ios/XPush/XPushBridge.h
- add the following import to
MainActivity.javaof your application
import com.facebook.react.shell.MainReactPackage;- add the following code to add the package to
MainActivity.java
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new XPushPackage() //this
);
}- add the following codes to your
android/setting.gradle
you might have multiple 3rd party libraries, make sure that you don't create multiple include.
include ':app', ':xpush-client'
project(':xpush-client').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-xpush-client/android/lib')
- edit
android/app/build.gradleand add the following line insidedependencies
compile project(':react-native-xpush-client')
- run
react-native run-androidto see if everything is compilable.
var XPush = require( 'react-native-xpush-client' );
// setting for server
XPush.init( 'http://54.178.160.166:8000', 'messengerx', userId, deviceId );
XPush.send( 'messageText' );