From 8f7668b060fdd7da946a69f027323345d613c23d Mon Sep 17 00:00:00 2001 From: Ulrich GIBERNE Date: Thu, 12 Dec 2024 15:50:48 -0400 Subject: [PATCH] add devTeam and default service extension --- .../AirshipNotificationService.swift | 8 ++++++++ plugin/src/withAirship.ts | 6 +++++- plugin/src/withAirshipIOS.ts | 10 ++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 plugin/NotificationServiceExtension/AirshipNotificationService.swift diff --git a/plugin/NotificationServiceExtension/AirshipNotificationService.swift b/plugin/NotificationServiceExtension/AirshipNotificationService.swift new file mode 100644 index 0000000..1b5ec9b --- /dev/null +++ b/plugin/NotificationServiceExtension/AirshipNotificationService.swift @@ -0,0 +1,8 @@ +// NotificationService.swift + + +import AirshipServiceExtension + +class AirshipNotificationService: UANotificationServiceExtension { + +} diff --git a/plugin/src/withAirship.ts b/plugin/src/withAirship.ts index 5fd6977..390b530 100644 --- a/plugin/src/withAirship.ts +++ b/plugin/src/withAirship.ts @@ -25,12 +25,16 @@ export type AirshipIOSPluginProps = { /** * Optional. The local path to a custom Notification Service Extension. */ - notificationService?: string; + notificationService?: 'DEFAULT_AIRSHIP_SERVICE_EXTENSION' | string; /** * Optional. Airship will use a default one if not provided. * The local path to a Notification Service Extension Info.plist. */ notificationServiceInfo?: string; + /** + * Optional. The Apple Development Team ID used to configure the Notification Service Extension target. + */ + developmentTeamID?: string; } export type AirshipPluginProps = { diff --git a/plugin/src/withAirshipIOS.ts b/plugin/src/withAirshipIOS.ts index 0831475..70b63dd 100644 --- a/plugin/src/withAirshipIOS.ts +++ b/plugin/src/withAirshipIOS.ts @@ -62,9 +62,10 @@ async function writeNotificationServiceFilesAsync(props: AirshipIOSPluginProps, } // Copy the NotificationService.swift file into the iOS expo project as AirshipNotificationService.swift. - readFile(props.notificationService, 'utf8', (err, data) => { + var notificationServiceFile = props.notificationService == "DEFAULT_AIRSHIP_SERVICE_EXTENSION" ? join(sourceDir, NOTIFICATION_SERVICE_FILE_NAME) : props.notificationService; + readFile(notificationServiceFile, 'utf8', (err, data) => { if (err || !data) { - console.error("Airship couldn't read file " + props.notificationService); + console.error("Airship couldn't read file " + notificationServiceFile); console.error(err); return; } @@ -160,9 +161,14 @@ const withExtensionTargetInXcodeProject: ConfigPlugin = ( const buildSettingsObj = configurations[key].buildSettings; buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = "14.0"; buildSettingsObj.SWIFT_VERSION = "5.0"; + buildSettingsObj.DEVELOPMENT_TEAM = props?.developmentTeamID; + buildSettingsObj.CODE_SIGN_STYLE = "Automatic"; } } + // Add development teams to the target + xcodeProject.addTargetAttribute("DevelopmentTeam", props?.developmentTeamID, notificationServiceExtensionTarget); + return newConfig; }); };