Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add google FCM dependency on iOS #12017

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .android.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export FCM_CONFIG_PROJECT_ID=
export FCM_CONFIG_STORAGE_BUCKET=
export FCM_CONFIG_MESSAGING_SENDER_ID=
export FCM_CONFIG_APP_ID=
export GOOGLE_SERVICES_B64=
export GOOGLE_SERVICES_B64_ANDROID=
#Notifications Feature Announcements
export FEATURES_ANNOUNCEMENTS_ACCESS_TOKEN=
export FEATURES_ANNOUNCEMENTS_SPACE_ID=
Expand Down
2 changes: 1 addition & 1 deletion .ios.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FCM_CONFIG_PROJECT_ID=
FCM_CONFIG_STORAGE_BUCKET=
FCM_CONFIG_MESSAGING_SENDER_ID=
FCM_CONFIG_APP_ID=
GOOGLE_SERVICES_B64=
GOOGLE_SERVICES_B64_IOS=
#Notifications Feature Announcements
FEATURES_ANNOUNCEMENTS_ACCESS_TOKEN=
FEATURES_ANNOUNCEMENTS_SPACE_ID=
3 changes: 2 additions & 1 deletion .js.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export FCM_CONFIG_PROJECT_ID=""
export FCM_CONFIG_STORAGE_BUCKET=""
export FCM_CONFIG_MESSAGING_SENDER_ID=""
export FCM_CONFIG_APP_ID=""
export GOOGLE_SERVICES_B64=""
export GOOGLE_SERVICES_B64_ANDROID=""
export GOOGLE_SERVICES_B64_IOS=""
#Notifications Feature Announcements
export FEATURES_ANNOUNCEMENTS_ACCESS_TOKEN=
export FEATURES_ANNOUNCEMENTS_SPACE_ID=
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ cd metamask-mobile

**Firebase Messaging Setup**

Before running the app, keep in mind that MetaMask uses FCM (Firebase Cloud Message) to empower communications. Based on this, as an external contributor you would preferably need to provide your own FREE Firebase project config file with a matching client for package name `io.metamask`, and update your `google-services.json` file in the `android/app` directory as well your `.env` files (`.ios.env`, `.js.env`, `.android.env`), adding `GOOGLE_SERVICES_B64` variable depending on the environment you are running the app (ios/android).
Before running the app, keep in mind that MetaMask uses FCM (Firebase Cloud Message) to empower communications. Based on this, as an external contributor you would preferably need to provide your own FREE Firebase project config file with a matching client for package name `io.metamask`, and update your `google-services.json` file in the `android/app` or `GoogleService-Info.plist` file in the `ios` directory. In case you don't have FCM account, you can use `./android/app/google-services-example.json` for Android or `./ios/GoogleServices/GoogleService-Info-example.plist` for iOS and follow the steps below to populate the correct environment variables in the `.env` files (`.ios.env`, `.js.env`, `.android.env`), adding `GOOGLE_SERVICES_B64_ANDROID` or `GOOGLE_SERVICES_B64_IOS` variable depending on the environment you are running the app (ios/android).

ATTENTION: In case you don't provide your own Firebase project config file, you can make use of a mock file at `android/app/google-services-example.json`, following the steps below from the root of the project:
The value you should provide to `GOOGLE_SERVICES_B64_ANDROID` or `GOOGLE_SERVICES_B64_IOS` is the base64 encoded version of your Firebase project config file, which can be generated as follows:

**For Android**
```bash
echo "export GOOGLE_SERVICES_B64=\"$(base64 -w0 -i ./android/app/google-services-example.json)\"" | tee -a .js.env .ios.env .android.env
echo "export GOOGLE_SERVICES_B64_ANDROID=\"$(base64 -w0 -i ./android/app/google-services-example.json)\"" | tee -a .js.env .android.env
```
**For iOS**
```bash
echo "export GOOGLE_SERVICES_B64_IOS=\"$(base64 -w0 -i ./ios/GoogleServices/GoogleService-Info-example.plist)\"" | tee -a .js.env .ios.env

You can make usage of a mock file at `android/app/google-services-example.json`, following the same steps above from the root of the project.
> [!CAUTION]
> In case you don't provide your own Firebase project config file or run the steps above, you will face the error `No matching client found for package name 'io.metamask'`.

In case of any doubt, please follow the instructions in the link below to get your Firebase project config file.

Expand Down
8 changes: 8 additions & 0 deletions ios/MetaMask.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
B339FF3C289ABF2C001B89FB /* MetaMask-QA-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B339FEA72899852C001B89FB /* MetaMask-QA-Info.plist */; };
B638844E306CAE9147B52C85 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; };
BF39E5BAE0F34F9091FF6AC0 /* EuclidCircularB-Semibold.otf in Resources */ = {isa = PBXBuildFile; fileRef = A8DE9C5BC0714D648276E123 /* EuclidCircularB-Semibold.otf */; };
C8D97A522CCAE1F6006EA92D /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C8D97A512CCAE1F6006EA92D /* GoogleService-Info.plist */; };
C8D97A532CCAE1F6006EA92D /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C8D97A512CCAE1F6006EA92D /* GoogleService-Info.plist */; };
C8D97A542CCAE1F6006EA92D /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C8D97A512CCAE1F6006EA92D /* GoogleService-Info.plist */; };
CD13D926E1E84D9ABFE672C0 /* Roboto-BlackItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3E2492C67CF345CABD7B8601 /* Roboto-BlackItalic.ttf */; };
CF9895772A3B49BE00B4C9B5 /* RCTMinimizer.m in Sources */ = {isa = PBXBuildFile; fileRef = CF9895762A3B49BE00B4C9B5 /* RCTMinimizer.m */; };
CF9895782A3B49BE00B4C9B5 /* RCTMinimizer.m in Sources */ = {isa = PBXBuildFile; fileRef = CF9895762A3B49BE00B4C9B5 /* RCTMinimizer.m */; };
Expand Down Expand Up @@ -302,6 +305,7 @@
BCC95B62DD6241678CDF73B3 /* CentraNo1-BookItalic.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "CentraNo1-BookItalic.otf"; path = "../app/fonts/CentraNo1-BookItalic.otf"; sourceTree = "<group>"; };
BF485CDA047B4D52852B87F5 /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf"; sourceTree = "<group>"; };
C752564A28B44392AEE16BD5 /* Roboto-Medium.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "Roboto-Medium.ttf"; path = "../app/fonts/Roboto-Medium.ttf"; sourceTree = "<group>"; };
C8D97A512CCAE1F6006EA92D /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
C9FD3FB1258A41A5A0546C83 /* Roboto-BoldItalic.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "Roboto-BoldItalic.ttf"; path = "../app/fonts/Roboto-BoldItalic.ttf"; sourceTree = "<group>"; };
CE0434C5FB7C4C6F9FEBDCE2 /* EuclidCircularB-Medium.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "EuclidCircularB-Medium.otf"; path = "../app/fonts/EuclidCircularB-Medium.otf"; sourceTree = "<group>"; };
CF014205BB8964CFE74D4D8E /* Pods-MetaMask-QA.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MetaMask-QA.release.xcconfig"; path = "Target Support Files/Pods-MetaMask-QA/Pods-MetaMask-QA.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -533,6 +537,7 @@
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
C8D97A512CCAE1F6006EA92D /* GoogleService-Info.plist */,
2EF283352B17EC4E00D7B4B1 /* Light-Swift-Untar-V2 */,
2EF283312B17EC1A00D7B4B1 /* RNTar.m */,
2EF283292B17EBD600D7B4B1 /* RnTar.swift */,
Expand Down Expand Up @@ -765,6 +770,7 @@
EF65C42EA15B4774B1947A12 /* Roboto-Medium.ttf in Resources */,
DC6A024F56DD43E1A83B47B1 /* Roboto-MediumItalic.ttf in Resources */,
34CEE49BC79D411687B42FA9 /* Roboto-Regular.ttf in Resources */,
C8D97A532CCAE1F6006EA92D /* GoogleService-Info.plist in Resources */,
7E08FB90F3754D47994208B4 /* Roboto-Thin.ttf in Resources */,
7C0226ABD9694AEDBAF3016F /* Roboto-ThinItalic.ttf in Resources */,
15ACC9FB226555820063978B /* LaunchScreen.xib in Resources */,
Expand Down Expand Up @@ -819,6 +825,7 @@
2EF282802B0FF86900D7B4B1 /* EuclidCircularB-BoldItalic.otf in Resources */,
2EF282812B0FF86900D7B4B1 /* EuclidCircularB-Light.otf in Resources */,
2EF282822B0FF86900D7B4B1 /* EuclidCircularB-LightItalic.otf in Resources */,
C8D97A522CCAE1F6006EA92D /* GoogleService-Info.plist in Resources */,
2EF282832B0FF86900D7B4B1 /* EuclidCircularB-Medium.otf in Resources */,
2EF282842B0FF86900D7B4B1 /* EuclidCircularB-MediumItalic.otf in Resources */,
2EF282852B0FF86900D7B4B1 /* EuclidCircularB-Regular.otf in Resources */,
Expand All @@ -840,6 +847,7 @@
B339FF15289ABD70001B89FB /* Roboto-BlackItalic.ttf in Resources */,
B339FF16289ABD70001B89FB /* Roboto-Bold.ttf in Resources */,
B339FF17289ABD70001B89FB /* debug.xcconfig in Resources */,
C8D97A542CCAE1F6006EA92D /* GoogleService-Info.plist in Resources */,
B339FF18289ABD70001B89FB /* Roboto-BoldItalic.ttf in Resources */,
B339FF19289ABD70001B89FB /* Roboto-Italic.ttf in Resources */,
B339FF1A289ABD70001B89FB /* Roboto-Light.ttf in Resources */,
Expand Down
1 change: 1 addition & 0 deletions ios/MetaMask/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#import <Firebase.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>

Expand Down
3 changes: 2 additions & 1 deletion ios/MetaMask/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "AppDelegate.h"
#import <Firebase.h>
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
Expand Down Expand Up @@ -60,7 +61,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

//Uncomment the following line to enable the splashscreen on ios
//[RNSplashScreen show];

[FIRApp configure];
return YES;
}

Expand Down
25 changes: 19 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ prebuild(){

prebuild_ios(){
prebuild

# Create GoogleService-Info.plist file to be used by the Firebase services.
# Check if GOOGLE_SERVICES_B64_IOS is set
if [ ! -z "$GOOGLE_SERVICES_B64_IOS" ]; then
echo -n $GOOGLE_SERVICES_B64_IOS | base64 -d > ./ios/GoogleService-Info.plist
echo "GoogleService-Info.plist has been created successfully."
# Ensure the file has read and write permissions
chmod 664 ./ios/GoogleService-Info.plist
else
echo "GOOGLE_SERVICES_B64_IOS is not set in the .env file."
exit 1
fi

# Generate xcconfig files for CircleCI
if [ "$PRE_RELEASE" = true ] ; then
echo "" > ios/debug.xcconfig
Expand All @@ -190,13 +203,13 @@ prebuild_android(){
# Copy fonts with iconset
yes | cp -rf ./app/fonts/Metamask.ttf ./android/app/src/main/assets/fonts/Metamask.ttf

#Create google-services.json file to be used by the Firebase services.
# Check if GOOGLE_SERVICES_B64 is set
if [ ! -z "$GOOGLE_SERVICES_B64" ]; then
echo -n $GOOGLE_SERVICES_B64 | base64 -d > ./android/app/google-services.json
# Create google-services.json file to be used by the Firebase services.
# Check if GOOGLE_SERVICES_B64_ANDROID is set
if [ ! -z "$GOOGLE_SERVICES_B64_ANDROID" ]; then
echo -n $GOOGLE_SERVICES_B64_ANDROID | base64 -d > ./android/app/google-services.json
echo "google-services.json has been created successfully."
else
echo "GOOGLE_SERVICES_B64 is not set in the .env file."
echo "GOOGLE_SERVICES_B64_ANDROID is not set in the .env file."
exit 1
fi

Expand Down Expand Up @@ -629,4 +642,4 @@ else
else
envFileMissing $ANDROID_ENV_FILE
fi
fi
fi
Loading