1
+ package org .jall .reactnative .firebase ;
2
+
3
+ import android .app .Activity ;
4
+ import android .util .Log ;
5
+
6
+ import com .facebook .react .bridge .ReactApplicationContext ;
7
+ import com .facebook .react .bridge .ReactContextBaseJavaModule ;
8
+ import com .facebook .react .bridge .ReactMethod ;
9
+ import com .google .firebase .remoteconfig .FirebaseRemoteConfig ;
10
+
11
+ public class FBRemoteConfig extends ReactContextBaseJavaModule {
12
+ public Activity activity ;
13
+
14
+ public FBRemoteConfig (ReactApplicationContext reactContext , Activity activity ) {
15
+ super (reactContext );
16
+ this .activity = activity ;
17
+ }
18
+
19
+ @ Override
20
+ public String getName () {
21
+ return "FBRemoteConfig" ;
22
+ }
23
+
24
+ @ ReactMethod
25
+ public boolean activateFetched (Promise promise ) {
26
+ promise .resolve (
27
+ FirebaseRemoteConfig .getInstance ().activateFetched ()
28
+ );
29
+ }
30
+
31
+ @ ReactMethod
32
+ public void fetch () {
33
+ FirebaseRemoteConfig .getInstance ().fetch ();
34
+ }
35
+
36
+ @ ReactMethod
37
+ public void fetchWithExpirationDuration (long cacheExpirationSeconds ) {
38
+ FirebaseRemoteConfig .getInstance ().fetch (cacheExpirationSeconds );
39
+ }
40
+
41
+ @ ReactMethod
42
+ public void getNamespacedBoolean (String key , String namespace , Promise promise ) {
43
+ promise .resolve (
44
+ FirebaseRemoteConfig .getInstance ().getBoolean (key , namespace )
45
+ );
46
+ }
47
+
48
+ @ ReactMethod
49
+ public void getBoolean (String key , Promise promise ) {
50
+ promise .resolve (
51
+ FirebaseRemoteConfig .getInstance ().getBoolean (key )
52
+ );
53
+ }
54
+
55
+ @ ReactMethod
56
+ public void getNamespacedDouble (String key , String namespace , Promise promise ) {
57
+ promise .resolve (
58
+ FirebaseRemoteConfig .getInstance ().getDouble (key , namespace )
59
+ );
60
+ }
61
+
62
+ @ ReactMethod
63
+ public void getDouble (String key , Promise promise ) {
64
+ promise .resolve (
65
+ FirebaseRemoteConfig .getInstance ().getDouble (key )
66
+ );
67
+ }
68
+
69
+ @ ReactMethod
70
+ public boolean getNamespacedLong (String key , String namespace , Promise promise ) {
71
+ promise .resolve (
72
+ FirebaseRemoteConfig .getInstance ().getLong (key , namespace )
73
+ );
74
+ }
75
+
76
+ @ ReactMethod
77
+ public boolean getLong (String key , Promise promise ) {
78
+ promise .resolve (
79
+ FirebaseRemoteConfig .getInstance ().getLong (key )
80
+ );
81
+ }
82
+
83
+ @ ReactMethod
84
+ public boolean getNamespacedString (String key , String namespace , Promise promise ) {
85
+ promise .resolve (
86
+ FirebaseRemoteConfig .getInstance ().getString (key , namespace )
87
+ );
88
+ }
89
+
90
+ @ ReactMethod
91
+ public boolean getString (String key , Promise promise ) {
92
+ promise .resolve (
93
+ FirebaseRemoteConfig .getInstance ().getString (key )
94
+ );
95
+ }
96
+
97
+ @ ReactMethod
98
+ public void setNamespacedDefaults (final ReadableMap defaults , String namespace ) {
99
+ FirebaseRemoteConfig .getInstance ().setDefaults (
100
+ ((ReadableNativeMap )defaults ).toHashMap (),
101
+ namespace
102
+ );
103
+ }
104
+
105
+ @ ReactMethod
106
+ public void setDefaults (final ReadableMap defaults ) {
107
+ FirebaseRemoteConfig .getInstance ().setDefaults (
108
+ ((ReadableNativeMap )defaults ).toHashMap ()
109
+ );
110
+ }
111
+ }
0 commit comments