Skip to content

Commit d0221af

Browse files
authored
feat: integrate firebase sdk for ios and android (#21983)
This change re-introduces the Firebase SDK via a react-native library. This has been done to support remote notifications via push-notifications from Firebase Cloud Messaging. This initial integration supports receiving FCM notifications on both iOS and Android platforms. This change also attempts to ensure that FDroid builds will not include Firebase or Google Play Services inside the build.
1 parent f4bb321 commit d0221af

File tree

53 files changed

+3335
-455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3335
-455
lines changed

.env.jenkins

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ SENTRY_ENABLED=0
4141
SENTRY_ENVIRONMENT=ci-main
4242
USE_PUBLIC_LOG_DIR=0
4343
VIEW_ID_TRACKER=1
44+
GOOGLE_FREE=0

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ build-fdroid: export BUILD_ENV = prod
209209
build-fdroid: export BUILD_TYPE = release
210210
build-fdroid: export ANDROID_ABI_SPLIT = false
211211
build-fdroid: export ANDROID_ABI_INCLUDE = armeabi-v7a;arm64-v8a;x86;x86_64
212+
build-fdroid: export ANDROID_STORE = fdroid
212213
build-fdroid: ##@build Build release for F-Droid
214+
@scripts/google-free.sh
213215
@scripts/build-android.sh
214216

215217
build-android: export BUILD_ENV ?= prod

android/app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,8 @@ task hemroidBuild(type: Exec) {
339339
preBuild.dependsOn hemroidBuild
340340

341341
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
342+
343+
def googleServicesConfigFile = "./googleServices.gradle";
344+
if (project.file(googleServicesConfigFile).exists()) {
345+
apply from: file(googleServicesConfigFile)
346+
}

android/app/google-services.json

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"project_info": {
3+
"project_number": "854811651919",
4+
"firebase_url": "https://status-react-app.firebaseio.com",
5+
"project_id": "status-react-app",
6+
"storage_bucket": "status-react-app.appspot.com"
7+
},
8+
"client": [
9+
{
10+
"client_info": {
11+
"mobilesdk_app_id": "1:854811651919:android:11ee7444ded8a00a",
12+
"android_client_info": {
13+
"package_name": "im.status.ethereum"
14+
}
15+
},
16+
"oauth_client": [
17+
{
18+
"client_id": "854811651919-gua52csicclb5p9gr4eeu33ukk0aaphj.apps.googleusercontent.com",
19+
"client_type": 3
20+
}
21+
],
22+
"api_key": [
23+
{
24+
"current_key": "AIzaSyAOF4W1j8GYeXzzVKRfNKlXywD6bx0rJtQ"
25+
}
26+
],
27+
"services": {
28+
"appinvite_service": {
29+
"other_platform_oauth_client": [
30+
{
31+
"client_id": "854811651919-gua52csicclb5p9gr4eeu33ukk0aaphj.apps.googleusercontent.com",
32+
"client_type": 3
33+
},
34+
{
35+
"client_id": "854811651919-30s20e3l0me0ins0vc4185jbnj7ja49o.apps.googleusercontent.com",
36+
"client_type": 2,
37+
"ios_info": {
38+
"bundle_id": "im.status.ethereum"
39+
}
40+
}
41+
]
42+
}
43+
}
44+
},
45+
{
46+
"client_info": {
47+
"mobilesdk_app_id": "1:854811651919:android:15dbe4af1e06ca3e005f3a",
48+
"android_client_info": {
49+
"package_name": "im.status.ethereum.debug"
50+
}
51+
},
52+
"oauth_client": [
53+
{
54+
"client_id": "854811651919-gua52csicclb5p9gr4eeu33ukk0aaphj.apps.googleusercontent.com",
55+
"client_type": 3
56+
}
57+
],
58+
"api_key": [
59+
{
60+
"current_key": "AIzaSyAOF4W1j8GYeXzzVKRfNKlXywD6bx0rJtQ"
61+
}
62+
],
63+
"services": {
64+
"appinvite_service": {
65+
"other_platform_oauth_client": [
66+
{
67+
"client_id": "854811651919-gua52csicclb5p9gr4eeu33ukk0aaphj.apps.googleusercontent.com",
68+
"client_type": 3
69+
},
70+
{
71+
"client_id": "854811651919-30s20e3l0me0ins0vc4185jbnj7ja49o.apps.googleusercontent.com",
72+
"client_type": 2,
73+
"ios_info": {
74+
"bundle_id": "im.status.ethereum"
75+
}
76+
}
77+
]
78+
}
79+
}
80+
},
81+
{
82+
"client_info": {
83+
"mobilesdk_app_id": "1:854811651919:android:1d0d69fe8c1bb89b005f3a",
84+
"android_client_info": {
85+
"package_name": "im.status.ethereum.pr"
86+
}
87+
},
88+
"oauth_client": [
89+
{
90+
"client_id": "854811651919-gua52csicclb5p9gr4eeu33ukk0aaphj.apps.googleusercontent.com",
91+
"client_type": 3
92+
}
93+
],
94+
"api_key": [
95+
{
96+
"current_key": "AIzaSyAOF4W1j8GYeXzzVKRfNKlXywD6bx0rJtQ"
97+
}
98+
],
99+
"services": {
100+
"appinvite_service": {
101+
"other_platform_oauth_client": [
102+
{
103+
"client_id": "854811651919-gua52csicclb5p9gr4eeu33ukk0aaphj.apps.googleusercontent.com",
104+
"client_type": 3
105+
},
106+
{
107+
"client_id": "854811651919-30s20e3l0me0ins0vc4185jbnj7ja49o.apps.googleusercontent.com",
108+
"client_type": 2,
109+
"ios_info": {
110+
"bundle_id": "im.status.ethereum"
111+
}
112+
}
113+
]
114+
}
115+
}
116+
}
117+
],
118+
"configuration_version": "1"
119+
}

android/app/googleServices.gradle

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Exclude google library so we can publish to external android stores
3+
*/
4+
5+
def googleFree = project.env.get("GOOGLE_FREE", "0") == '1'
6+
7+
if (!googleFree) {
8+
apply plugin: 'com.google.gms.google-services'
9+
}
10+
11+
dependencies {
12+
if (googleFree) {
13+
implementation(project(':react-native-firebase_app')) {
14+
exclude group: 'com.google.firebase'
15+
exclude group: 'com.google.gms'
16+
}
17+
18+
implementation(project(':react-native-firebase_messaging')) {
19+
exclude group: 'com.google.firebase'
20+
exclude group: 'com.google.gms'
21+
}
22+
} else {
23+
implementation 'com.google.firebase:firebase-messaging:24.1.0'
24+
}
25+
}

android/app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
android:name="android.support.FILE_PROVIDER_PATHS"
125125
android:resource="@xml/file_provider_paths" />
126126
</provider>
127+
<meta-data
128+
android:name="com.google.firebase.messaging.default_notification_icon"
129+
android:resource="@drawable/notification_icon" />
130+
<meta-data
131+
android:name="com.google.firebase.messaging.default_notification_color"
132+
android:resource="@color/notification_icon_color" tools:replace="android:resource" />
127133
</application>
128134

129135
</manifest>

android/app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
<color name="alert_text">#000000</color>
55
<color name="splash_background">#09101C</color>
66
<color name="splash_status_bar_color">#ffffff</color>
7+
<color name="notification_icon_color">#4360DF</color>
78
</resources>

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ buildscript {
3131
classpath("com.android.tools.build:gradle")
3232
classpath("com.facebook.react:react-native-gradle-plugin")
3333
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
34+
classpath("com.google.gms:google-services:4.4.2")
3435
}
3536
}
3637

doc/fdroid.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,71 @@ You can provide `--storage-opt size=30G` flag if Docker complains about running
127127

128128
You should also run `lint` and `rewritemeta` for the App ID to verify and fix the YAML metadata formatting.
129129

130+
# Scanning Builds Locally
131+
132+
Based on the documentation provided here: https://gitlab.com/fdroid/wiki/-/wikis/Tips-for-fdroiddata-contributors/Setting-up-app-submission-development-environment-locally
133+
134+
We can locally scan our source code and pre-built APKS by using the FDroid CLI tool. We can prepare a FDroid environment by
135+
following [the steps mentioned in these instructions](https://gitlab.com/fdroid/wiki/-/wikis/Tips-for-fdroiddata-contributors/Setting-up-app-submission-development-environment-locally).
136+
* Note, at the time of writing (March 2025), the easiest way to follow these instructions involved:
137+
* Creating a new empty directory outside of the status-mobile repository.
138+
* For this example, let's refer to this directory as `status-fdroid-server`
139+
* Then git cloning the two referenced git repos inside the `status-fdroid-server` directory:
140+
```shell
141+
git clone https://gitlab.com/fdroid/fdroiddata.git --depth=1
142+
git clone https://gitlab.com/fdroid/fdroidserver.git --depth=1
143+
```
144+
* Then create a subdirectory inside `status-fdroid-server` named `apks`
145+
* Then create a subdirectory inside `status-fdroid-server` named `scripts`
146+
* Create a file inside the `scripts` folder named `env.sh`
147+
```shell
148+
source /etc/profile.d/bsenv.sh
149+
export GRADLE_USER_HOME=$home_vagrant/.gradle
150+
export fdroid="sudo --preserve-env --user vagrant
151+
env PATH=$fdroidserver:$PATH
152+
env PYTHONPATH=$fdroidserver:$fdroidserver/examples
153+
env PYTHONUNBUFFERED=true
154+
env TERM=$TERM
155+
env HOME=$home_vagrant
156+
fdroid"
157+
158+
export build=im.status.ethereum
159+
```
160+
* Create a file inside the `scripts` folder named `prep.sh`
161+
```shell
162+
apt-get update && apt-get install -y make xz-utils
163+
```
164+
* Create a file inside the `scripts` folder named `run.sh`
165+
```shell
166+
docker run --rm -i -t --privileged --pid=host --entrypoint "/bin/bash" \
167+
-v ${ANDROID_SDK_ROOT}:/opt/android-sdk:Z \
168+
-v $(pwd)/fdroidserver:/home/vagrant/fdroidserver:Z \
169+
-v $(pwd)/scripts:/scripts:z \
170+
-v $(pwd)/fdroiddata:/build:z \
171+
-v $(pwd)/apks:/apks:z \
172+
registry.gitlab.com/fdroid/fdroidserver:buildserver
173+
```
174+
* Create a file inside the `scripts` folder named `latest-version-code.sh`
175+
```shell
176+
prefix="versionCode: "
177+
resultLine=$(grep $prefix ./metadata/$build.yml | tail -n 1)
178+
echo $resultLine | sed -e "s/^$prefix//"
179+
```
180+
* Then inside a terminal shell run the following command:
181+
* `env ANDROID_SDK_ROOT=<insert sdk directory> sh scripts/run.sh`
182+
* Ensure you replace `<insert sdk directory>` with the path to Android SDK folder.
183+
* On macOS, the value could be: `$HOME/Library/Android/sdk`
184+
* Once inside the Docker shell environment run the following commands:
185+
* `sh /scripts/prep.sh`
186+
* This command should install `xz` utils packages for installing the Nix package manager.
187+
* `source /scripts/env.sh`
188+
* This command should populate the Docker shell environment with the `$fdroid` command.
189+
* Next we can run `cd /build` to enter the `fdroiddata` directory that has been mounted inside the docker environment.
190+
* And now we can run `$fdroid scanner $build:$(sh /scripts/latest-version-code.sh)` to scan the latest version of the status app that has been registered in the `fdroiddata/metadata/im.status.ethereum.yml` file.
191+
* Alternatively, we can also copy an APK into the `apks` folder and run `$fdroid scanner /apks/<insert-apk-file-name>`.
192+
* Ensure that you replace the `<insert-apk-file-name>` with the correct name of the pre-built APK.
193+
* For example, after running `make release-fdroid`, you can copy the `app-arm64-v8a-release-unsigned.apk` file into the `apks` folder and run `$fdroid scanner /apks/app-arm64-v8arelease-unsigned.apk` inside the docker shell environment.
194+
130195
# Details
131196

132197
The original research was done in [#8512](https://github.com/status-im/status-mobile/issues/8512).

ios/GoogleService-Info.plist

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>API_KEY</key>
6+
<string>AIzaSyAm5D6giymR_2llh-8SbCRL3oPxX_v3EZs</string>
7+
<key>GCM_SENDER_ID</key>
8+
<string>854811651919</string>
9+
<key>PLIST_VERSION</key>
10+
<string>1</string>
11+
<key>BUNDLE_ID</key>
12+
<string>im.status.ethereum</string>
13+
<key>PROJECT_ID</key>
14+
<string>status-react-app</string>
15+
<key>STORAGE_BUCKET</key>
16+
<string>status-react-app.appspot.com</string>
17+
<key>IS_ADS_ENABLED</key>
18+
<false></false>
19+
<key>IS_ANALYTICS_ENABLED</key>
20+
<false></false>
21+
<key>IS_APPINVITE_ENABLED</key>
22+
<true></true>
23+
<key>IS_GCM_ENABLED</key>
24+
<true></true>
25+
<key>IS_SIGNIN_ENABLED</key>
26+
<true></true>
27+
<key>GOOGLE_APP_ID</key>
28+
<string>1:854811651919:ios:11ee7444ded8a00a</string>
29+
<key>DATABASE_URL</key>
30+
<string>https://status-react-app.firebaseio.com</string>
31+
</dict>
32+
</plist>

0 commit comments

Comments
 (0)