I see that the setup of background delivery for iOS in your Expo plugin was done in a brittle way (by manually patching the app delegate file):
|
const withTerraBackgroundDelivery: ConfigPlugin = (config) => { |
|
config = withAppDelegate(config, (delegateConfig) => { |
|
const { contents } = delegateConfig.modResults; |
|
|
|
if (delegateConfig.modResults.language === 'swift') { |
|
if (!delegateConfig.modResults.contents.includes('import TerraiOS')) { |
|
delegateConfig.modResults.contents = |
|
`import TerraiOS\n` + delegateConfig.modResults.contents; |
|
} |
|
|
|
if ( |
|
!delegateConfig.modResults.contents.includes( |
|
'Terra.setUpBackgroundDelivery()' |
|
) |
|
) { |
|
const regex = |
|
/return super.application\(application, didFinishLaunchingWithOptions: launchOptions\)/; |
|
delegateConfig.modResults.contents = |
|
delegateConfig.modResults.contents.replace( |
|
regex, |
|
(match) => `Terra.setUpBackgroundDelivery()\n ${match}` |
|
); |
|
} |
|
} else { |
|
if (!contents.includes('#import <TerraiOS/TerraiOS-Swift.h>')) { |
|
delegateConfig.modResults.contents = contents.replace( |
|
'#import "AppDelegate.h"', |
|
'#import "AppDelegate.h"\n#import <TerraiOS/TerraiOS-Swift.h>' |
|
); |
|
} |
|
|
|
if (!contents.includes('[Terra setUpBackgroundDelivery];')) { |
|
const regex = |
|
/- \(BOOL\)application:\(UIApplication \*\)application didFinishLaunchingWithOptions:\(NSDictionary \*\)launchOptions\s*\{\n/; |
|
delegateConfig.modResults.contents = |
|
delegateConfig.modResults.contents.replace( |
|
regex, |
|
(match) => `${match} [Terra setUpBackgroundDelivery];\n` |
|
); |
|
} |
|
} |
|
|
|
return delegateConfig; |
|
}); |
|
|
|
return config; |
|
}; |
I believe that Expo has a better way (docs) for this.
I actually implemented that in my custom Terra Expo plugin, which I created before you guys offered one: app delegate, config.
Maybe this could be improved in your Expo plugin. (Feel free to reuse my code!)
I see that the setup of background delivery for iOS in your Expo plugin was done in a brittle way (by manually patching the app delegate file):
terra-react/plugin/src/index.ts
Lines 7 to 53 in 1536fc2
I believe that Expo has a better way (docs) for this.
I actually implemented that in my custom Terra Expo plugin, which I created before you guys offered one: app delegate, config.
Maybe this could be improved in your Expo plugin. (Feel free to reuse my code!)