diff --git a/android/app/build.gradle b/android/app/build.gradle
index 0ed9d11..8e02467 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -160,7 +160,7 @@ dependencies {
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-image-resizer')
-// implementation project(':react-native-device-info')
+ implementation project(':react-native-device-info')
implementation project(':react-native-vector-icons')
implementation project(':@react-native-community_async-storage')
implementation project(':react-native-navigation')
@@ -170,15 +170,10 @@ dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.tencent.xinge:xinge:4.3.2-release'
- //jg包
implementation'com.tencent.jg:jg:1.1'
- //wup包
implementation 'com.tencent.wup:wup:1.0.0.E-Release'
- //mid包,minSdkVersion 14
implementation 'com.tencent.mid:mid:4.0.7-Release'
- compile 'com.tencent.xinge:xghw:2.5.2.300-release'
- compile 'com.tencent.xinge:mipush:3.2.2-release'
- compile 'com.tencent.xinge:xgmz:3.2.2-release'
+ implementation 'com.tencent.xinge:mipush:4.3.2-xiaomi-release'
}
// Run this once to be able to run the application with BUCK
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index b67b990..64fd04f 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -29,6 +29,9 @@
+
+
+
diff --git a/android/app/src/main/java/com/timepill/MainApplication.java b/android/app/src/main/java/com/timepill/MainApplication.java
index f00d7ce..cdfb905 100644
--- a/android/app/src/main/java/com/timepill/MainApplication.java
+++ b/android/app/src/main/java/com/timepill/MainApplication.java
@@ -7,7 +7,7 @@ import com.rain.day.XGPushPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import fr.bamlab.rnimageresizer.ImageResizerPackage;
-//import com.learnium.RNDeviceInfo.RNDeviceInfo;
+import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.facebook.react.ReactNativeHost;
@@ -46,7 +46,7 @@ public class MainApplication extends NavigationApplication {
return Arrays.asList(
// eg. new VectorIconsPackage()
new RNFetchBlobPackage(),
- //new RNDeviceInfo(),
+ new RNDeviceInfo(),
new VectorIconsPackage(),
new AsyncStoragePackage(),
new PickerPackage(),
diff --git a/android/build.gradle b/android/build.gradle
index 568ac1d..20b032c 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -7,6 +7,14 @@ buildscript {
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
+
+ /*
+ 解决 react-native-device-info 依赖冲突问题
+ react-native-device-info 默认引用最新版 gcm 包,进而依赖 androidx 包
+ 0.59 react native 不兼容 androidx
+ 所以这里指定 gcm 版本
+ */
+ googlePlayServicesVersion = "11.0.4"
}
repositories {
google()
diff --git a/android/settings.gradle b/android/settings.gradle
index 006c82f..e71b56a 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -22,5 +22,5 @@ project(':@react-native-community_async-storage').projectDir = new File(rootProj
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
-//include ':react-native-device-info'
-//project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
+include ':react-native-device-info'
+project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
diff --git a/index.js b/index.js
index 96bc711..83ec26f 100644
--- a/index.js
+++ b/index.js
@@ -13,6 +13,7 @@ import Api from './src/util/api';
import PageList from './src/page/_list';
import BottomNav from './src/nav/bottomNav';
+import Push from './src/util/push';
// for debug
console.disableYellowBox = true;
@@ -106,5 +107,8 @@ Navigation.events().registerAppLaunchedListener(async () => {
}
}
+ Push.init((msg) => {
+ console.log("push init: " + msg)
+ })
});
diff --git a/src/util/push.js b/src/util/push.js
new file mode 100644
index 0000000..8a5812c
--- /dev/null
+++ b/src/util/push.js
@@ -0,0 +1,52 @@
+import {NativeModules, Platform} from 'react-native';
+import XGPushModule from 'react-native-smart-xgpush';
+const XGPushNativeModules = NativeModules.XGPushModule;
+
+function init(cb) {
+ XGPushNativeModules.enableDebug(true);
+ if(Platform.OS ==='android'){
+ XGPushModule.notifyJSDidLoad(() => {
+ XGPushModule.registerPush();
+ initOtherPush();
+ cb()
+ });
+ } else {
+ cb()
+ }
+}
+
+function initOtherPush() {
+ XGPushNativeModules.enableOtherPush(true);
+
+ const appId = '2882303761517764099';
+ const appKey = '5341776464099';
+ XGPushNativeModules.initXiaomi(appId, appKey);
+
+ addReceiveNotificationListener(null);
+}
+
+function setAccount(uid, cb) {
+ if(Platform.OS === 'ios'){
+ XGPushModule.setAccount(uid,cb);
+ }else{
+ XGPushModule.bindAccount(uid,cb);
+ }
+}
+
+function addReceiveNotificationListener(cb) {
+ XGPushModule.addReceiveNotificationListener((map) => {
+ console.log("[ReceiveNotification]", map)
+ });
+
+ XGPushModule.addReceiveOpenNotificationListener((msg) => {
+ console.log("[addReceiveOpenNotificationListener]", msg)
+
+ })
+}
+
+
+
+export default {
+ init,
+ setAccount,
+}
\ No newline at end of file