Skip to content

Commit 71e0bcb

Browse files
committed
expo: remove manual notification delegate in pre-build
1 parent e4ca119 commit 71e0bcb

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

plugin/src/__tests__/withReactNativeBatchAppDelegate.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1+
import { appDelegateExpectedFixture, appDelegateFixture } from '../fixtures/appDelegate';
12
import { modifyAppDelegate } from '../ios/withReactNativeBatchAppDelegate';
2-
import {
3-
appDelegateExpectedFixture,
4-
appDelegateFixture,
5-
} from '../fixtures/appDelegate';
63

74
describe(modifyAppDelegate, () => {
85
it('should modify the AppDelegate', () => {

plugin/src/fixtures/appDelegate.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ static void InitializeFlipper(UIApplication *application) {
157157

158158
export const appDelegateExpectedFixture = `#import "AppDelegate.h"
159159
160-
#import <RNBatchPush/RNBatch.h>
161-
162160
#if defined(EX_DEV_MENU_ENABLED)
163161
@import EXDevMenu;
164162
#endif
@@ -210,7 +208,6 @@ static void InitializeFlipper(UIApplication *application) {
210208
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
211209
{
212210
[RNBatch start];
213-
[BatchUNUserNotificationCenterDelegate registerAsDelegate];
214211
215212
#if defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>)
216213
InitializeFlipper(application);

plugin/src/ios/withReactNativeBatchAppDelegate.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';
2-
import { Props } from '../withReactNativeBatch';
32

43
const DID_FINISH_LAUNCHING_WITH_OPTIONS_DECLARATION =
54
'- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{';
65

7-
const IMPORT_BATCH = '\n\n#import <RNBatchPush/RNBatch.h>\n';
8-
const REGISTER_BATCH = '\n [RNBatch start];\n [BatchUNUserNotificationCenterDelegate registerAsDelegate];\n';
6+
const REGISTER_BATCH = '\n [RNBatch start];\n';
97

108
export const modifyAppDelegate = (contents: string) => {
11-
contents = contents.replace('\n', IMPORT_BATCH);
9+
const [beforeDeclaration, afterDeclaration] = contents.split(DID_FINISH_LAUNCHING_WITH_OPTIONS_DECLARATION);
1210

13-
const [beforeDeclaration, afterDeclaration] = contents.split(
14-
DID_FINISH_LAUNCHING_WITH_OPTIONS_DECLARATION
15-
);
16-
17-
const newAfterDeclaration = DID_FINISH_LAUNCHING_WITH_OPTIONS_DECLARATION.concat(
18-
REGISTER_BATCH
19-
).concat(afterDeclaration);
11+
const newAfterDeclaration = DID_FINISH_LAUNCHING_WITH_OPTIONS_DECLARATION.concat(REGISTER_BATCH).concat(afterDeclaration);
2012

2113
contents = beforeDeclaration.concat(newAfterDeclaration);
2214
return contents;
2315
};
2416

25-
export const withReactNativeBatchAppDelegate: ConfigPlugin<{} | void> = config => {
17+
export const withReactNativeBatchAppDelegate: ConfigPlugin<object | void> = config => {
2618
return withAppDelegate(config, config => {
2719
config.modResults.contents = modifyAppDelegate(config.modResults.contents);
2820
return config;

0 commit comments

Comments
 (0)