@@ -5,38 +5,15 @@ import {
55} from '@expo/config-plugins' ;
66import type { IntercomPluginProps } from './@types' ;
77import {
8- addObjcImports ,
98 findObjcFunctionCodeBlock ,
109 insertContentsInsideObjcFunctionBlock ,
1110} from '@expo/config-plugins/build/ios/codeMod' ;
1211
1312const appDelegate : ConfigPlugin < IntercomPluginProps > = ( _config ) =>
1413 withAppDelegate ( _config , ( config ) => {
15- const pushCode = `
16- // START INTERCOM PUSH
17- UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
18- [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound)
19- completionHandler:^(BOOL granted, NSError *_Nullable error) {
20- }];
21- [[UIApplication sharedApplication] registerForRemoteNotifications];
22- // END INTERCOM PUSH
23- ` ;
24-
2514 const setDeviceTokenCode = '[IntercomModule setDeviceToken:deviceToken];' ;
2615
2716 let stringContents = config . modResults . contents ;
28- stringContents = addObjcImports ( stringContents , [
29- '<UserNotifications/UserNotifications.h>' ,
30- ] ) ;
31-
32- if ( ! stringContents . includes ( pushCode . trim ( ) ) ) {
33- stringContents = insertContentsInsideObjcFunctionBlock (
34- stringContents ,
35- 'application didFinishLaunchingWithOptions:' ,
36- pushCode ,
37- { position : 'tailBeforeLastReturn' }
38- ) ;
39- }
4017
4118 const didRegisterBlock = findObjcFunctionCodeBlock (
4219 stringContents ,
0 commit comments