Skip to content

Commit 30703f7

Browse files
committed
Modify AppDelegate and fix iOS specific issues - need to handle webview
1 parent 75cb072 commit 30703f7

File tree

10 files changed

+6128
-6191
lines changed

10 files changed

+6128
-6191
lines changed

app/store/index.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ const createStoreAndPersistor = async () => {
4444

4545
const middlewares = [sagaMiddleware, thunk];
4646

47-
if (__DEV__) {
48-
// Add redux flipper middleware for debugging Redux with Flipper
49-
// Flipper's client side plugin is https://github.com/jk-gan/flipper-plugin-redux-debugger, which needs to be added as a plugin
50-
// flipper-plugin-redux-debugger is named redux-debugger in Flipper's plugin list
51-
/* eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
52-
const createReduxFlipperDebugger = require('redux-flipper').default;
53-
middlewares.push(createReduxFlipperDebugger());
54-
}
47+
// if (__DEV__) {
48+
// Add redux flipper middleware for debugging Redux with Flipper
49+
// Flipper's client side plugin is https://github.com/jk-gan/flipper-plugin-redux-debugger, which needs to be added as a plugin
50+
// flipper-plugin-redux-debugger is named redux-debugger in Flipper's plugin list
51+
/* eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
52+
// const createReduxFlipperDebugger = require('redux-flipper').default;
53+
// middlewares.push(createReduxFlipperDebugger());
54+
// }
5555

5656
store = configureStore({
5757
reducer: pReducer,

ios/MetaMask.xcodeproj/project.pbxproj

+10-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
49D8E62C506F4A63889EEC7F /* branch.json in Resources */ = {isa = PBXBuildFile; fileRef = FE3C9A2458A1416290DEDAD4 /* branch.json */; };
8383
4CEFC9E34A8D4288BFE2F85A /* Roboto-Light.ttf in Resources */ = {isa = PBXBuildFile; fileRef = BB8BA2D3C0354D6090B56A8A /* Roboto-Light.ttf */; };
8484
5A6FB59C323F4F188B3F52C4 /* CentraNo1-Book.otf in Resources */ = {isa = PBXBuildFile; fileRef = 88A1BA779A344AC6B03514CA /* CentraNo1-Book.otf */; };
85-
650F2B9D24DC5FF200C3B9C4 /* libRCTAesForked.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 650F2B9C24DC5FEC00C3B9C4 /* libRCTAesForked.a */; };
8685
654378B0243E2ADC00571B9C /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 654378AF243E2ADC00571B9C /* File.swift */; };
8786
7696E77F73B5ADD7EE8190E0 /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7EEA32C976A46B991D55FD4 /* ExpoModulesProvider.swift */; };
8887
7C0226ABD9694AEDBAF3016F /* Roboto-ThinItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CF552F79C77A4184A690513A /* Roboto-ThinItalic.ttf */; };
@@ -341,7 +340,6 @@
341340
buildActionMask = 2147483647;
342341
files = (
343342
F961A37228105CF9007442B5 /* LinkPresentation.framework in Frameworks */,
344-
650F2B9D24DC5FF200C3B9C4 /* libRCTAesForked.a in Frameworks */,
345343
153C1ABB2217BCDC0088EFE0 /* JavaScriptCore.framework in Frameworks */,
346344
153F84CA2319B8FD00C19B63 /* Branch.framework in Frameworks */,
347345
ED2E8FE6D71BE9319F3B27D3 /* libPods-MetaMask.a in Frameworks */,
@@ -1407,7 +1405,7 @@
14071405
"$(SRCROOT)/../node_modules/react-native-tcp/ios/**",
14081406
);
14091407
INFOPLIST_FILE = MetaMask/Info.plist;
1410-
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
1408+
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
14111409
LD_RUNPATH_SEARCH_PATHS = (
14121410
"$(inherited)",
14131411
"@executable_path/Frameworks",
@@ -1473,7 +1471,7 @@
14731471
"$(SRCROOT)/../node_modules/react-native-tcp/ios/**",
14741472
);
14751473
INFOPLIST_FILE = MetaMask/Info.plist;
1476-
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
1474+
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
14771475
LD_RUNPATH_SEARCH_PATHS = (
14781476
"$(inherited)",
14791477
"@executable_path/Frameworks",
@@ -1670,6 +1668,10 @@
16701668
ONLY_ACTIVE_ARCH = YES;
16711669
OTHER_CFLAGS = "$(inherited)";
16721670
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
1671+
"OTHER_CPLUSPLUSFLAGS[arch=*]" = (
1672+
"$(inherited)",
1673+
"-DFOLLY_CFG_NO_COROUTINES=1",
1674+
);
16731675
OTHER_LDFLAGS = "$(inherited)";
16741676
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
16751677
SDKROOT = iphoneos;
@@ -1716,6 +1718,10 @@
17161718
MTL_ENABLE_DEBUG_INFO = NO;
17171719
OTHER_CFLAGS = "$(inherited)";
17181720
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
1721+
"OTHER_CPLUSPLUSFLAGS[arch=*]" = (
1722+
"$(inherited)",
1723+
"-DFOLLY_CFG_NO_COROUTINES=1",
1724+
);
17191725
OTHER_LDFLAGS = "$(inherited)";
17201726
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
17211727
SDKROOT = iphoneos;

ios/MetaMask/AppDelegate.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
#import <Expo/Expo.h>
33
#import <React/RCTBridgeDelegate.h>
44
#import <UIKit/UIKit.h>
5+
#import <UserNotifications/UserNotifications.h>
56

6-
@interface AppDelegate : EXAppDelegateWrapper <UIApplicationDelegate, RCTBridgeDelegate>
7+
@interface AppDelegate : EXAppDelegateWrapper <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>
78

89
@property (nonatomic, strong) UIWindow *window;
910

ios/MetaMask/AppDelegate.m

+58-90
Original file line numberDiff line numberDiff line change
@@ -5,136 +5,104 @@
55
#import <React/RCTRootView.h>
66
#import <React/RCTPushNotificationManager.h>
77
#import <RNBranch/RNBranch.h>
8-
#if DEBUG
9-
#ifdef FB_SONARKIT_ENABLED
10-
#import <FlipperKit/FlipperClient.h>
11-
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
12-
#import <FlipperKitLayoutPlugin/SKDescriptorMapper.h>
13-
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
14-
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
15-
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
16-
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
17-
#endif
18-
#endif
8+
#import <UserNotifications/UserNotifications.h>
199

2010
#if DEBUG
2111
#include <EXDevLauncher/EXDevLauncherController.h>
2212
#endif
2313

24-
@implementation AppDelegate
14+
#import <Expo/Expo.h> // Required for `EXReactDelegateWrapper`
2515

26-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
16+
@interface AppDelegate ()
2717

28-
self.moduleName = @"MetaMask";
18+
@property (nonatomic, strong) EXReactDelegateWrapper *reactDelegate;
2919

30-
[FIRApp configure];
31-
NSString *foxCodeFromBundle = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"fox_code"];
20+
@end
3221

33-
NSString *foxCode;
22+
@implementation AppDelegate
3423

35-
if(foxCodeFromBundle != nil){
36-
foxCode = foxCodeFromBundle;
37-
} else {
38-
foxCode = @"debug";
39-
}
24+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
4025

41-
// Uncomment this line to use the test key instead of the live one.
42-
// [RNBranch useTestInstance];
43-
[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
44-
NSURL *jsCodeLocation;
26+
self.moduleName = @"MetaMask";
4527

46-
RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions];
47-
RCTRootView *rootView = [self.reactDelegate createRootViewWithBridge:bridge
48-
moduleName:@"MetaMask"
49-
initialProperties:@{@"foxCode": foxCode}];
28+
// Initialize Firebase
29+
if ([FIRApp defaultApp] == nil) {
30+
[FIRApp configure];
31+
}
5032

51-
self.initialProps = @{@"foxCode": foxCode};
5233

53-
rootView.backgroundColor = [UIColor colorNamed:@"ThemeColors"];
34+
// Initialize Branch.io
35+
[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
5436

37+
NSString *foxCodeFromBundle = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"fox_code"];
38+
NSString *foxCode = foxCodeFromBundle ? foxCodeFromBundle : @"debug";
39+
40+
// Create RootViewController
5541
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
56-
UIViewController *rootViewController = [self.reactDelegate createRootViewController];
57-
rootViewController.view = rootView;
42+
UIViewController *rootViewController = [self createRootViewController];
5843
self.window.rootViewController = rootViewController;
5944
[self.window makeKeyAndVisible];
6045

61-
//Keep splash screen while loading the bundle
62-
UIView* launchScreenView = [[[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil] objectAtIndex:0];
63-
launchScreenView.frame = self.window.bounds;
64-
rootView.loadingView = launchScreenView;
46+
self.initialProps = @{@"foxCode": foxCode};
6547

66-
[self initializeFlipper:application];
48+
// Register for Push Notifications
49+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
50+
center.delegate = self;
51+
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge)
52+
completionHandler:^(BOOL granted, NSError * _Nullable error) {
53+
if (!error) {
54+
dispatch_async(dispatch_get_main_queue(), ^{
55+
[application registerForRemoteNotifications];
56+
});
57+
}
58+
}];
59+
60+
return [super application:application didFinishLaunchingWithOptions:launchOptions];
61+
}
6762

68-
//Uncomment the following line to enable the splashscreen on ios
69-
//[RNSplashScreen show];
7063

71-
[super application:application didFinishLaunchingWithOptions:launchOptions];
64+
// Push Notification Registration
65+
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
66+
[RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
67+
}
7268

73-
return YES;
69+
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
70+
[RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
7471
}
7572

76-
- (void) initializeFlipper:(UIApplication *)application {
77-
#if DEBUG
78-
#ifdef FB_SONARKIT_ENABLED
79-
FlipperClient *client = [FlipperClient sharedClient];
80-
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
81-
[client addPlugin: [[FlipperKitLayoutPlugin alloc] initWithRootNode: application withDescriptorMapper: layoutDescriptorMapper]];
82-
[client addPlugin: [[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
83-
[client addPlugin: [FlipperKitReactPlugin new]];
84-
[client addPlugin: [[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
85-
[client start];
86-
#endif
87-
#endif
73+
// Handle Push Notifications
74+
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
75+
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
76+
[RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
8877
}
8978

90-
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
91-
{
79+
// Handle Deep Links (Branch.io)
80+
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
9281
#if DEBUG
9382
if ([EXDevLauncherController.sharedInstance onDeepLink:url options:options]) {
94-
return true;
83+
return YES;
9584
}
9685
#endif
9786
return [RNBranch application:app openURL:url options:options];
9887
}
9988

89+
// Handle Universal Links
10090
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
10191
return [RNBranch continueUserActivity:userActivity];
10292
}
10393

104-
// Required to register for notifications
105-
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
106-
{
107-
[RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
108-
}
109-
// Required for the register event.
110-
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
111-
{
112-
[RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
113-
}
114-
// Required for the notification event. You must call the completion handler after handling the remote notification.
115-
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
116-
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
117-
{
118-
[RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
119-
}
120-
// Required for the registrationError event.
121-
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
122-
{
123-
[RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
124-
}
125-
// Required for the localNotification event.
126-
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
127-
{
128-
[RCTPushNotificationManager didReceiveLocalNotification:notification];
94+
// Get Bundle URL for React Native
95+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
96+
#if DEBUG
97+
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"];
98+
#else
99+
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
100+
#endif
129101
}
130102

131-
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
132-
{
133-
#if DEBUG
134-
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"];
135-
#else
136-
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
137-
#endif
103+
// ✅ This method is inherited from EXAppDelegateWrapper
104+
- (UIViewController *)createRootViewController {
105+
return [super createRootViewController];
138106
}
139107

140108
@end

ios/Podfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
source 'https://github.com/CocoaPods/Specs.git'
12
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
23
require_relative '../node_modules/react-native/scripts/react_native_pods'
34
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

metro.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ module.exports = function (baseConfig) {
2323
},
2424
transformer: {
2525
babelTransformerPath: require.resolve('./metro.transform.js'),
26-
assetPlugins: ['react-native-svg-asset-plugin'],
26+
assetPlugins: [
27+
'react-native-svg-asset-plugin',
28+
'expo-asset/tools/hashAssetFiles', // ✅ Added expo-asset plugin
29+
],
2730
svgAssetPlugin: {
2831
pngCacheDir: '.png-cache',
2932
scales: [1],

package.json

+9-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"gem:bundle:install": "bundle install --gemfile=ios/Gemfile",
1212
"clean:ppom": "rm -rf ppom/dist ppom/node_modules app/lib/ppom/ppom.html.js",
1313
"clean:android": "rm -rf android/app/build",
14-
"clean:node": "rm -rf node_modules && yarn --frozen-lockfile",
14+
"clean:node": "rm -rf node_modules && yarn",
1515
"clean": "yarn clean:ios && yarn clean:android && yarn clean:node && yarn clean:ppom",
1616
"clean-android": "yarn clean:android && yarn clean:node",
1717
"lint": "eslint '**/*.{js,ts,tsx}'",
@@ -190,7 +190,6 @@
190190
"@metamask/react-native-button": "^3.0.0",
191191
"@metamask/react-native-payments": "^2.0.0",
192192
"@metamask/react-native-search-api": "1.0.1",
193-
"@metamask/react-native-webview": "^14.0.4",
194193
"@metamask/remote-feature-flag-controller": "^1.0.0",
195194
"@metamask/rpc-errors": "^7.0.1",
196195
"@metamask/scure-bip39": "^2.1.0",
@@ -266,6 +265,7 @@
266265
"eventemitter2": "^6.4.9",
267266
"events": "3.0.0",
268267
"expo": "^52.0.28",
268+
"expo-asset": "^11.0.3",
269269
"expo-build-properties": "~0.11.1",
270270
"expo-dev-client": "^5.0.10",
271271
"expo-dev-menu": "^6.0.18",
@@ -275,8 +275,8 @@
275275
"humanize-duration": "^3.27.2",
276276
"is-url": "^1.2.4",
277277
"lodash": "^4.17.21",
278-
"lottie-ios": "^4.3.3",
279-
"lottie-react-native": "^7.0.0",
278+
"lottie-ios": "4.5.0",
279+
"lottie-react-native": "7.2.2",
280280
"mockttp": "^3.15.2",
281281
"multihashes": "0.4.14",
282282
"number-to-bn": "1.7.0",
@@ -350,6 +350,7 @@
350350
"react-native-vector-icons": "6.4.2",
351351
"react-native-video": "5.2.1",
352352
"react-native-view-shot": "3.8.0",
353+
"react-native-webview": "^13.13.2",
353354
"react-native-webview-invoke": "^0.6.2",
354355
"react-redux": "^8.1.3",
355356
"readable-stream": "2.3.7",
@@ -400,7 +401,7 @@
400401
"@react-native-community/cli": "15.0.1",
401402
"@react-native-community/cli-platform-android": "15.0.1",
402403
"@react-native-community/cli-platform-ios": "15.0.1",
403-
"@react-native/metro-config": "^0.72.12",
404+
"@react-native/metro-config": "^0.78.0-rc.0",
404405
"@rpii/wdio-html-reporter": "^7.7.1",
405406
"@sentry/types": "^7.117.0",
406407
"@storybook/addon-actions": "^7.5.1",
@@ -483,6 +484,7 @@
483484
"koa": "^2.14.2",
484485
"lint-staged": "10.5.4",
485486
"listr2": "^8.0.2",
487+
"metro-react-native-babel-preset": "^0.77.0",
486488
"multiple-cucumber-html-reporter": "^3.0.1",
487489
"nock": "^13.3.1",
488490
"nyc": "^15.1.0",
@@ -499,7 +501,6 @@
499501
"react-native-svg-asset-plugin": "^0.5.0",
500502
"react-native-svg-transformer": "^1.0.0",
501503
"react-test-renderer": "18.3.1",
502-
"redux-flipper": "^2.0.3",
503504
"redux-saga-test-plan": "^4.0.6",
504505
"regenerator-runtime": "0.13.9",
505506
"rn-nodeify": "10.3.0",
@@ -603,7 +604,8 @@
603604
"appium": false,
604605
"appium>@appium/support>sharp": false,
605606
"@metamask/eth-ledger-bridge-keyring>@ledgerhq/hw-app-eth>@ledgerhq/domain-service>eip55>keccak": false,
606-
"$root$": false
607+
"$root$": false,
608+
"@storybook/builder-webpack5>@storybook/core-common>esbuild": false
607609
}
608610
},
609611
"packageManager": "[email protected]"

react-native.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// eslint-disable-next-line import/no-commonjs
33
module.exports = {
44
dependencies: {
5-
...(process.env.NO_FLIPPER
6-
? { 'react-native-flipper': { platforms: { ios: null } } }
7-
: {}),
85
'react-native-gesture-handler': {
96
platforms: {
107
android: {

scripts/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ buildIosSimulator(){
282282
SIM_OPTION=""
283283
fi
284284
#react-native run-ios --port=$WATCHER_PORT $SIM_OPTION
285-
npx expo run:ios --no-install --mode Debug --port $WATCHER_PORT $SIM_OPTION
285+
npx expo run:ios --no-install --port $WATCHER_PORT $SIM_OPTION
286286
}
287287

288288
buildIosSimulatorQA(){

0 commit comments

Comments
 (0)