diff --git a/.android.env.example b/.android.env.example index 93b4a8c334e..5c769312cca 100644 --- a/.android.env.example +++ b/.android.env.example @@ -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= diff --git a/.ios.env.example b/.ios.env.example index 05aadc9b359..cc449b8b6e1 100644 --- a/.ios.env.example +++ b/.ios.env.example @@ -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= diff --git a/.js.env.example b/.js.env.example index 81d9fea44a1..c151b882877 100644 --- a/.js.env.example +++ b/.js.env.example @@ -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= diff --git a/README.md b/README.md index 2d19b29c7f8..83c45efc3f4 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/ios/MetaMask.xcodeproj/project.pbxproj b/ios/MetaMask.xcodeproj/project.pbxproj index 314bc34f316..5cf71de41ed 100644 --- a/ios/MetaMask.xcodeproj/project.pbxproj +++ b/ios/MetaMask.xcodeproj/project.pbxproj @@ -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 */; }; @@ -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 = ""; }; 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 = ""; }; 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 = ""; }; + C8D97A512CCAE1F6006EA92D /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 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 = ""; }; 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 = ""; }; 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 = ""; }; @@ -533,6 +537,7 @@ 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( + C8D97A512CCAE1F6006EA92D /* GoogleService-Info.plist */, 2EF283352B17EC4E00D7B4B1 /* Light-Swift-Untar-V2 */, 2EF283312B17EC1A00D7B4B1 /* RNTar.m */, 2EF283292B17EBD600D7B4B1 /* RnTar.swift */, @@ -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 */, @@ -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 */, @@ -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 */, diff --git a/ios/MetaMask/AppDelegate.h b/ios/MetaMask/AppDelegate.h index ef1de86a2a8..17bcd2f078b 100644 --- a/ios/MetaMask/AppDelegate.h +++ b/ios/MetaMask/AppDelegate.h @@ -1,5 +1,6 @@ #import #import +#import @interface AppDelegate : UIResponder diff --git a/ios/MetaMask/AppDelegate.m b/ios/MetaMask/AppDelegate.m index b22d5678257..e8603d86561 100644 --- a/ios/MetaMask/AppDelegate.m +++ b/ios/MetaMask/AppDelegate.m @@ -1,4 +1,5 @@ #import "AppDelegate.h" +#import #import #import #import @@ -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; } diff --git a/scripts/build.sh b/scripts/build.sh index e9993f6d84b..085de3ab91d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -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 @@ -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 @@ -629,4 +642,4 @@ else else envFileMissing $ANDROID_ENV_FILE fi -fi \ No newline at end of file +fi