Skip to content

Instantly share code, notes, and snippets.

@anhtuank7c
Created August 27, 2024 13:49
Show Gist options
  • Save anhtuank7c/b650a252115b1d5711ad1e76d1c34572 to your computer and use it in GitHub Desktop.
Save anhtuank7c/b650a252115b1d5711ad1e76d1c34572 to your computer and use it in GitHub Desktop.
Expo Firebase patch that ensure to remove the auth session once app got deleted
diff --git a/node_modules/@react-native-firebase/app/plugin/build/ios/appDelegate.js b/node_modules/@react-native-firebase/app/plugin/build/ios/appDelegate.js
index 8cf92f0..7840ebb 100644
--- a/node_modules/@react-native-firebase/app/plugin/build/ios/appDelegate.js
+++ b/node_modules/@react-native-firebase/app/plugin/build/ios/appDelegate.js
@@ -7,7 +7,13 @@ exports.withFirebaseAppDelegate = exports.modifyAppDelegateAsync = exports.modif
const config_plugins_1 = require("@expo/config-plugins");
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
const fs_1 = __importDefault(require("fs"));
-const methodInvocationBlock = `[FIRApp configure];`;
+const methodInvocationBlock = `[FIRApp configure];
+NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+if (![defaults boolForKey:@"notFirstRun"]) {
+ [defaults setBool:YES forKey:@"notFirstRun"];
+ [defaults synchronize];
+ [[FIRAuth auth] signOut:NULL];
+}`;
// https://regex101.com/r/mPgaq6/1
const methodInvocationLineMatcher = /(?:self\.moduleName\s*=\s*@\"([^"]*)\";)|(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[(\[RCTBridge alloc\]|self\.reactDelegate))/g;
// https://regex101.com/r/nHrTa9/1/
diff --git a/node_modules/@react-native-firebase/app/plugin/src/ios/appDelegate.ts b/node_modules/@react-native-firebase/app/plugin/src/ios/appDelegate.ts
index b4ecbdf..42bdcd5 100644
--- a/node_modules/@react-native-firebase/app/plugin/src/ios/appDelegate.ts
+++ b/node_modules/@react-native-firebase/app/plugin/src/ios/appDelegate.ts
@@ -3,7 +3,13 @@ import { AppDelegateProjectFile } from '@expo/config-plugins/build/ios/Paths';
import { mergeContents } from '@expo/config-plugins/build/utils/generateCode';
import fs from 'fs';
-const methodInvocationBlock = `[FIRApp configure];`;
+const methodInvocationBlock = `[FIRApp configure];
+NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+if (![defaults boolForKey:@"notFirstRun"]) {
+ [defaults setBool:YES forKey:@"notFirstRun"];
+ [defaults synchronize];
+ [[FIRAuth auth] signOut:NULL];
+}`;
// https://regex101.com/r/mPgaq6/1
const methodInvocationLineMatcher =
/(?:self\.moduleName\s*=\s*@\"([^"]*)\";)|(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[(\[RCTBridge alloc\]|self\.reactDelegate))/g;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment