react-native-push-akoo
v1.1.0
Published
## Getting started
Downloads
4
Readme
react-native-push-akoo
Getting started
$ npm install react-native-push-akoo --save
Mostly automatic installation
$ react-native link react-native-push-akoo
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNPushAkooPackage;
to the imports at the top of the file - Add
new RNPushAkooPackage()
to the list returned by thegetPackages()
method
Append the following lines to
android/settings.gradle
:include ':react-native-push-akoo' project(':react-native-push-akoo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-akoo/android')
Insert the following lines inside the dependencies block in
android/app/build.gradle
:implementation project(":react-native-push-akoo")
public class MainActivity extends ReactActivity {
/**
- Returns the name of the main component registered from JavaScript.
- This is used to schedule rendering of the component.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RNPushAkooModule.miAppconfig("appid","appkey"); RNPushAkooModule.registerPush(this);
}
androidmenifest.xml
<meta-data
android:name="com.huawei.hms.client.appid"
android:value="xxxxxxxxxx">
Usage
import { NativeAppEventEmitter,Alert } from 'react-native';
NativeAppEventEmitter.addListener(
'receiveRemoteNotification',
(notification) => {
console.log(notification);
Alert.alert('消息通知',notification);
}
);
NativeAppEventEmitter.addListener(
'receiveClientId',
(notification) => {
console.log(notification);
Alert.alert('receiveClientId',notification);
}
);