mirror of
https://github.com/timepill/timepill-app.git
synced 2025-04-30 09:59:31 +08:00
push 初始化
This commit is contained in:
parent
73ece99d4e
commit
38d25d906f
7 changed files with 73 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
|
||||
|
||||
<uses-library android:name="org.apache.http.legacy" android:required="false" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
|
@ -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.<ReactPackage>asList(
|
||||
// eg. new VectorIconsPackage()
|
||||
new RNFetchBlobPackage(),
|
||||
//new RNDeviceInfo(),
|
||||
new RNDeviceInfo(),
|
||||
new VectorIconsPackage(),
|
||||
new AsyncStoragePackage(),
|
||||
new PickerPackage(),
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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')
|
||||
|
|
4
index.js
4
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)
|
||||
})
|
||||
});
|
||||
|
||||
|
|
52
src/util/push.js
Normal file
52
src/util/push.js
Normal file
|
@ -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,
|
||||
}
|
Loading…
Reference in a new issue