android 接入 firebase

This commit is contained in:
mx1700 2019-07-17 00:03:04 +08:00
parent ffc12f3e74
commit 44e14d1ed6
12 changed files with 86 additions and 13 deletions

View file

@ -1,4 +1,6 @@
apply plugin: "com.android.application"
apply plugin: "io.fabric"
import com.android.build.OutputFile
@ -107,10 +109,10 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5"
versionCode 21
versionName "2.0.1"
versionCode 22
versionName "2.0.2"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
ndk {
// cpu类型的.so库
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
@ -166,12 +168,15 @@ android {
dependencies {
implementation project(':react-native-firebase')
implementation project(':react-native-smart-xgpush')
implementation project(':rn-fetch-blob')
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')){
exclude group: 'com.google.android.gms'
}
implementation project(':react-native-vector-icons')
implementation project(':@react-native-community_async-storage')
implementation project(':react-native-navigation')
@ -185,6 +190,16 @@ dependencies {
implementation 'com.tencent.wup:wup:1.0.0.E-Release'
implementation 'com.tencent.mid:mid:4.0.7-Release'
implementation 'com.tencent.xinge:mipush:4.3.2-xiaomi-release'
// Firebase dependencies
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.9"
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
transitive = true
}
apply plugin: 'com.google.gms.google-services'
}
// Run this once to be able to run the application with BUCK

View file

@ -3,6 +3,8 @@ package com.timepill;
import android.app.Application;
import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage;
import com.rain.day.XGPushPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
@ -50,7 +52,9 @@ public class MainApplication extends NavigationApplication {
new VectorIconsPackage(),
new AsyncStoragePackage(),
new PickerPackage(),
new XGPushPackage()
new XGPushPackage(),
new RNFirebasePackage(),
new RNFirebaseCrashlyticsPackage()
);
}

View file

@ -21,10 +21,12 @@ buildscript {
mavenLocal()
mavenCentral()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.28.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
@ -41,5 +43,6 @@ allprojects {
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://jitpack.io' }
maven { url 'https://maven.fabric.io/public' }
}
}

View file

@ -1,4 +1,6 @@
rootProject.name = 'Timepill'
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':app'
include ':react-native-smart-xgpush'

View file

@ -14,6 +14,8 @@ import PageList from './src/page/_list';
import BottomNav from './src/nav/bottomNav';
import Push from './src/util/push';
import firebase from 'react-native-firebase';
// for debug
console.disableYellowBox = true;
@ -96,6 +98,8 @@ Navigation.events().registerAppLaunchedListener(async () => {
}
try {
//todo:当服务器不可用时,可能会卡在这里很长时间
//之前的做法是异步更新数据,在下一次打开 app 时从本地读取
await Api.syncSplash();
} catch (err) {}
@ -118,5 +122,7 @@ Navigation.events().registerAppLaunchedListener(async () => {
Push.init((msg) => {
console.log("push init: " + msg);
})
firebase.crashlytics().log('Test Message!');
});

View file

@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@ -70,6 +69,7 @@
ED297163215061F000B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED297162215061F000B7C4FE /* JavaScriptCore.framework */; };
ED2971652150620600B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2971642150620600B7C4FE /* JavaScriptCore.framework */; };
F343A722A8DB46C79081F2A0 /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 81F0243DD71F467A964CAD89 /* Entypo.ttf */; };
0776D8FF93DB448E92CCCCAB /* libRNFirebase.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C138A37CA72349BF80C6081A /* libRNFirebase.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -498,6 +498,8 @@
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
FE0D7FAFEDE44E168687B4B2 /* RNCAsyncStorage.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNCAsyncStorage.xcodeproj; path = "../node_modules/@react-native-community/async-storage/ios/RNCAsyncStorage.xcodeproj"; sourceTree = "<group>"; };
578B633145B7404F91B43B90 /* RNFirebase.xcodeproj */ = {isa = PBXFileReference; name = "RNFirebase.xcodeproj"; path = "../node_modules/react-native-firebase/ios/RNFirebase.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
C138A37CA72349BF80C6081A /* libRNFirebase.a */ = {isa = PBXFileReference; name = "libRNFirebase.a"; path = "libRNFirebase.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -541,6 +543,7 @@
4156314F2297CFBE009EB583 /* QBImagePicker.framework in Frameworks */,
35DCFF50947D4FCBBF5A8921 /* libRNFetchBlob.a in Frameworks */,
7497C6D0D64344B197447DC7 /* libRCTXGPushModule.a in Frameworks */,
0776D8FF93DB448E92CCCCAB /* libRNFirebase.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -828,6 +831,7 @@
BDBA91D5680B4ACA83A7844B /* imageCropPicker.xcodeproj */,
99151F1A82BD48E0B5416458 /* RNFetchBlob.xcodeproj */,
461950EE4FD949249DD2937B /* RCTXGPushModule.xcodeproj */,
578B633145B7404F91B43B90 /* RNFirebase.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
@ -1599,6 +1603,7 @@
"$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**",
"$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**",
"$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule",
"$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**",
);
INFOPLIST_FILE = TimepillTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
@ -1614,6 +1619,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1640,6 +1646,7 @@
"$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**",
"$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**",
"$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule",
"$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**",
);
INFOPLIST_FILE = TimepillTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
@ -1655,6 +1662,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1683,6 +1691,7 @@
"$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**",
"$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**",
"$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule",
"$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**",
);
INFOPLIST_FILE = Timepill/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1713,6 +1722,7 @@
"$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**",
"$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**",
"$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule",
"$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**",
);
INFOPLIST_FILE = Timepill/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1748,6 +1758,7 @@
"$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**",
"$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**",
"$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule",
"$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**",
);
INFOPLIST_FILE = "Timepill-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1762,6 +1773,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1796,6 +1808,7 @@
"$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**",
"$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**",
"$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule",
"$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**",
);
INFOPLIST_FILE = "Timepill-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -1810,6 +1823,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1843,6 +1857,7 @@
"$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**",
"$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**",
"$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule",
"$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**",
);
INFOPLIST_FILE = "Timepill-tvOSTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -1857,6 +1872,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
@ -1890,6 +1906,7 @@
"$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**",
"$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**",
"$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule",
"$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**",
);
INFOPLIST_FILE = "Timepill-tvOSTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -1904,6 +1921,7 @@
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",

14
package-lock.json generated
View file

@ -10237,6 +10237,11 @@
}
}
},
"opencollective-postinstall": {
"version": "2.0.2",
"resolved": "https://registry.npm.taobao.org/opencollective-postinstall/download/opencollective-postinstall-2.0.2.tgz",
"integrity": "sha1-Vlfxvt5ptuM6RZObBh61PTxsOok="
},
"opn": {
"version": "3.0.3",
"resolved": "http://registry.npm.taobao.org/opn/download/opn-3.0.3.tgz",
@ -10864,6 +10869,15 @@
"prop-types": "^15.5.8"
}
},
"react-native-firebase": {
"version": "5.5.5",
"resolved": "https://registry.npm.taobao.org/react-native-firebase/download/react-native-firebase-5.5.5.tgz",
"integrity": "sha1-1cfgLrbqVlD567sjws15b4PnykU=",
"requires": {
"opencollective-postinstall": "^2.0.0",
"prop-types": "^15.7.2"
}
},
"react-native-image-crop-picker": {
"version": "0.24.0",
"resolved": "https://registry.npm.taobao.org/react-native-image-crop-picker/download/react-native-image-crop-picker-0.24.0.tgz",

View file

@ -16,6 +16,7 @@
"react-native-datepicker": "^1.7.2",
"react-native-device-info": "^1.6.1",
"react-native-elements": "^0.19.0",
"react-native-firebase": "^5.5.5",
"react-native-image-crop-picker": "^0.24.0",
"react-native-image-pan-zoom": "^2.1.11",
"react-native-image-progress": "^1.1.1",

View file

@ -171,7 +171,7 @@ export default class NotificationList extends Component {
});
if(this.props.isSetRead) {
//this._setRead(msg);
this._setRead(msg);
}
}

View file

@ -1,6 +1,7 @@
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import {Navigation} from 'react-native-navigation';
import firebase from 'react-native-firebase';
import Color from '../style/color';
import {Icon} from '../style/icon';

View file

@ -12,6 +12,7 @@ import Api from "../util/api";
import Event from "../util/event";
import Notification from "../component/notification/notification";
import NotificationList from "../component/notification/notificationList";
import firebase from 'react-native-firebase';
const LOOP_TIME_SHORT = 30 * 1000;
const LOOP_TIME_LONG = 60 * 1000;
@ -141,9 +142,12 @@ export default class NotificationPage extends Component {
console.log('Push.setAccount ' + alias + ' ', success);
});
// Crashlytics.setUserName(user.name);
// Crashlytics.setUserEmail(user.email);
// Crashlytics.setUserIdentifier(user.id.toString());
console.log(user, user.email);
firebase.crashlytics().setUserIdentifier(user.id.toString());
firebase.crashlytics().setUserName(user.name);
//todo:现在用户信息里没有 email
//firebase.crashlytics().setUserEmail(user.email);
}

View file

@ -33,6 +33,11 @@ export default class UserInfoEditPage extends Component {
static options(passProps) {
return {
topBar: {
title: {
text: '修改个人信息'
}
},
statusBar: {
backgroundColor: 'white',
style: 'dark'