Guide | Documentation | Sample |
---|
npm install pushwoosh-react-native-plugin --save
In android/settings.gradle file, make the following changes:
...
include ':pushwooshplugin'
project(':pushwooshplugin').projectDir = new File(rootProject.projectDir, '../node_modules/pushwoosh-react-native-plugin/src/android')
In android/app/build.gradle add pushwooshplugin dependency:
dependencies {
...
compile project(':pushwooshplugin')
}
Optional: To use non-default play-service-gcm
version (the plugin uses 8.4.0), modify your android/app/build.gradle
dependencies.
This might be required in case of conflicts with other react-native plugins.
...
dependencies {
...
compile project(':pushwooshplugin')
compile ('com.google.android.gms:play-services-gcm:9.+') {force = true;}
compile ('com.google.android.gms:play-services-location:9.+') {force = true;}
}
For RN < v.0.29.0 In MainActivity.java add:
...
import com.pushwoosh.reactnativeplugin.PushwooshPackage;
public class MainActivity extends ReactActivity {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new PushwooshPackage() // register Pushwoosh plugin here
);
}
}
For RN >= v.0.29.0 In MainApplication.java add:
...
import com.pushwoosh.reactnativeplugin.PushwooshPackage;
public class MainApplication extends Application implements ReactApplication {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new PushwooshPackage() // register Pushwoosh plugin here
);
}
}
var Pushwoosh = require('pushwoosh-react-native-plugin');
Pushwoosh.init({ "pw_appid" : "YOUR_PUSHWOOSH_PROJECT_ID" , "project_number" : "YOUR_GCM_PROJECT_NUMBER" });
Pushwoosh.register();
npm install pushwoosh-react-native-plugin --save
Drag the PushwooshPlugin.xcodeproj (located in node_modules/pushwoosh-react-native-plugin/src/ios) as a dependency project into your React Native XCode project. Link your project with libPushwooshPlugin.a, libstdc++ and libz libraries.
var Pushwoosh = require('pushwoosh-react-native-plugin');
Pushwoosh.init({ "pw_appid" : "YOUR_PUSHWOOSH_PROJECT_ID" });
Pushwoosh.register();