customerio-expo-plugin 1.0.0-alpha.7 → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -166
- package/lib/commonjs/android/withAndroidManifestUpdates.js +37 -0
- package/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -0
- package/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
- package/lib/commonjs/android/withCIOAndroid.js +4 -0
- package/lib/commonjs/android/withCIOAndroid.js.map +1 -1
- package/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
- package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
- package/lib/commonjs/helpers/constants/android.js.map +1 -1
- package/lib/commonjs/helpers/constants/ios.js +27 -4
- package/lib/commonjs/helpers/constants/ios.js.map +1 -1
- package/lib/commonjs/helpers/native-files/ios/PushService.swift +1 -13
- package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -1
- package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ios/withAppDelegateModifications.js +8 -4
- package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js +48 -27
- package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/commonjs/ios/withXcodeProject.js.map +1 -1
- package/lib/commonjs/postInstall.js.map +1 -1
- package/lib/commonjs/postInstallHelper.js.map +1 -1
- package/lib/commonjs/types/cio-types.js.map +1 -1
- package/lib/module/android/withAndroidManifestUpdates.js +30 -0
- package/lib/module/android/withAndroidManifestUpdates.js.map +1 -0
- package/lib/module/android/withAppGoogleServices.js.map +1 -1
- package/lib/module/android/withCIOAndroid.js +4 -0
- package/lib/module/android/withCIOAndroid.js.map +1 -1
- package/lib/module/android/withGistMavenRepository.js.map +1 -1
- package/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/lib/module/android/withProjectGoogleServices.js.map +1 -1
- package/lib/module/helpers/constants/ios.js +25 -3
- package/lib/module/helpers/constants/ios.js.map +1 -1
- package/lib/module/helpers/native-files/ios/PushService.swift +1 -13
- package/lib/module/helpers/utils/codeInjection.js.map +1 -1
- package/lib/module/helpers/utils/fileManagement.js.map +1 -1
- package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/ios/withAppDelegateModifications.js +8 -4
- package/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/module/ios/withCIOIos.js.map +1 -1
- package/lib/module/ios/withNotificationsXcodeProject.js +49 -27
- package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/module/ios/withXcodeProject.js.map +1 -1
- package/lib/module/postInstall.js.map +1 -1
- package/lib/module/postInstallHelper.js.map +1 -1
- package/lib/module/types/cio-types.js.map +1 -1
- package/lib/typescript/android/withAndroidManifestUpdates.d.ts +3 -0
- package/lib/typescript/helpers/constants/ios.d.ts +5 -4
- package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -1
- package/lib/typescript/types/cio-types.d.ts +2 -0
- package/package.json +5 -2
- package/src/android/withAndroidManifestUpdates.ts +49 -0
- package/src/android/withCIOAndroid.ts +4 -0
- package/src/helpers/constants/ios.ts +31 -3
- package/src/helpers/native-files/ios/PushService.swift +1 -13
- package/src/ios/withAppDelegateModifications.ts +14 -6
- package/src/ios/withNotificationsXcodeProject.ts +76 -28
- package/src/types/cio-types.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","replaceCodeByRegex","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function replaceCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, snippet);\n}\n\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n"],"mappings":"AAAA,OAAO,SAASA,
|
|
1
|
+
{"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","replaceCodeByRegex","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function replaceCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, snippet);\n}\n\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n"],"mappings":"AAAA,OAAO,SAASA,iBAAiBA,CAC/BC,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKN,SAAS,CAACO,IAAI,CAACD,IAAI,CAAC,CAAC;EAC7D,IAAIE,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB;AAEA,OAAO,SAASE,0BAA0BA,CACxCX,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,OAAMC,OAAQ,EAAC,CAAC;AACzD;AAEA,OAAO,SAASW,kBAAkBA,CAChCb,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAEC,OAAO,CAAC;AAChD;AAEA,OAAO,SAASY,wCAAwCA,CACtDd,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,GAAEC,OAAQ,EAAC,CAAC;AACrD;AAEA,OAAO,SAASa,sBAAsBA,CACpCf,WAAmB,EACnBK,KAAa,EACbH,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,IAAIK,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["readFile","writeFile","appendFile","existsSync","copyFileSync","mkdirSync","writeFileSync","readFileSync","FileManagement","read","path","Promise","resolve","reject","err","data","write","contents","append","exists","copyFile","src","dest","console","log","mkdir","options"],"sources":["fileManagement.ts"],"sourcesContent":["import {\n readFile,\n writeFile,\n appendFile,\n existsSync,\n copyFileSync,\n mkdirSync,\n writeFileSync,\n readFileSync,\n MakeDirectoryOptions,\n} from 'fs';\n\nexport class FileManagement {\n static async read(path: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n readFile(path, 'utf8', (err, data) => {\n if (err || !data) {\n reject(err);\n return;\n }\n resolve(data);\n });\n });\n }\n\n static async write(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n writeFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static async append(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n appendFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static exists(path: string) {\n return existsSync(path);\n }\n\n static copyFile(src: string, dest: string) {\n try {\n copyFileSync(src, dest);\n } catch (err) {\n console.log(`Error copying file from ${src} to ${dest}: `, err);\n }\n }\n\n static mkdir(path: string, options: MakeDirectoryOptions) {\n try {\n mkdirSync(path, options);\n } catch (err) {\n console.log(`Error creating directory ${path}: `, err);\n }\n }\n\n static writeFile(path: string, data: string) {\n try {\n writeFileSync(path, data);\n } catch (err) {\n console.log(`Error writing to file ${path}: `, err);\n }\n }\n\n static readFile(path: string) {\n try {\n return readFileSync(path, 'utf-8');\n } catch (err) {\n console.log(`Error reading file ${path}: `, err);\n }\n\n return '';\n }\n}\n"],"mappings":"AAAA,SACEA,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,SAAS,EACTC,aAAa,EACbC,YAAY,QAEP,IAAI;AAEX,OAAO,MAAMC,cAAc,CAAC;EAC1B,aAAaC,
|
|
1
|
+
{"version":3,"names":["readFile","writeFile","appendFile","existsSync","copyFileSync","mkdirSync","writeFileSync","readFileSync","FileManagement","read","path","Promise","resolve","reject","err","data","write","contents","append","exists","copyFile","src","dest","console","log","mkdir","options"],"sources":["fileManagement.ts"],"sourcesContent":["import {\n readFile,\n writeFile,\n appendFile,\n existsSync,\n copyFileSync,\n mkdirSync,\n writeFileSync,\n readFileSync,\n MakeDirectoryOptions,\n} from 'fs';\n\nexport class FileManagement {\n static async read(path: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n readFile(path, 'utf8', (err, data) => {\n if (err || !data) {\n reject(err);\n return;\n }\n resolve(data);\n });\n });\n }\n\n static async write(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n writeFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static async append(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n appendFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static exists(path: string) {\n return existsSync(path);\n }\n\n static copyFile(src: string, dest: string) {\n try {\n copyFileSync(src, dest);\n } catch (err) {\n console.log(`Error copying file from ${src} to ${dest}: `, err);\n }\n }\n\n static mkdir(path: string, options: MakeDirectoryOptions) {\n try {\n mkdirSync(path, options);\n } catch (err) {\n console.log(`Error creating directory ${path}: `, err);\n }\n }\n\n static writeFile(path: string, data: string) {\n try {\n writeFileSync(path, data);\n } catch (err) {\n console.log(`Error writing to file ${path}: `, err);\n }\n }\n\n static readFile(path: string) {\n try {\n return readFileSync(path, 'utf-8');\n } catch (err) {\n console.log(`Error reading file ${path}: `, err);\n }\n\n return '';\n }\n}\n"],"mappings":"AAAA,SACEA,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,SAAS,EACTC,aAAa,EACbC,YAAY,QAEP,IAAI;AAEX,OAAO,MAAMC,cAAc,CAAC;EAC1B,aAAaC,IAAIA,CAACC,IAAY,EAAmB;IAC/C,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC9Cb,QAAQ,CAACU,IAAI,EAAE,MAAM,EAAE,CAACI,GAAG,EAAEC,IAAI,KAAK;QACpC,IAAID,GAAG,IAAI,CAACC,IAAI,EAAE;UAChBF,MAAM,CAACC,GAAG,CAAC;UACX;QACF;QACAF,OAAO,CAACG,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaC,KAAKA,CAACN,IAAY,EAAEO,QAAgB,EAAiB;IAChE,OAAO,IAAIN,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5CZ,SAAS,CAACS,IAAI,EAAEO,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QACzC,IAAIA,GAAG,EAAE;UACPD,MAAM,CAACC,GAAG,CAAC;UACX;QACF;QACAF,OAAO,CAAC,CAAC;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaM,MAAMA,CAACR,IAAY,EAAEO,QAAgB,EAAiB;IACjE,OAAO,IAAIN,OAAO,C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C;IAClD;IAEA,OAAO,EAAE;EACX;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CIO_PODFILE_REGEX","CIO_PODFILE_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET","CIO_PODFILE_NOTIFICATION_REGEX","CIO_CIO_TARGET_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","FileManagement","injectCIOPodfileCode","iosPath","filename","podfile","read","matches","match","targetMatch","lines","split","index","findIndex","line","test","content","slice","write","join","console","log","injectCIONotificationPodfileCode","useFrameworks","snippet","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport {\n CIO_PODFILE_REGEX,\n CIO_PODFILE_SNIPPET,\n CIO_PODFILE_NOTIFICATION_SNIPPET,\n CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET,\n CIO_PODFILE_NOTIFICATION_REGEX,\n CIO_CIO_TARGET_REGEX,\n CIO_PODFILE_POST_INSTALL_REGEX,\n} from '../constants/ios';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_REGEX);\n const targetMatch = podfile.match(CIO_CIO_TARGET_REGEX);\n\n if (!targetMatch) {\n const lines = podfile.split('\\n');\n const index = lines.findIndex((line) =>\n CIO_PODFILE_POST_INSTALL_REGEX.test(line)\n );\n let content: string[] = lines;\n if (index > -1) {\n content = [\n ...lines.slice(0, index - 1),\n !matches ? CIO_PODFILE_SNIPPET : '',\n ...lines.slice(index - 1),\n ];\n }\n\n FileManagement.write(filename, content.join('\\n'));\n } else {\n console.log('Customerio Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_NOTIFICATION_REGEX);\n\n if (!matches) {\n const snippet =\n useFrameworks === 'static'\n ? CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET\n : CIO_PODFILE_NOTIFICATION_SNIPPET;\n FileManagement.append(filename, snippet);\n }\n}\n"],"mappings":"AACA,SACEA,iBAAiB,EACjBC,mBAAmB,EACnBC,gCAAgC,EAChCC,iDAAiD,EACjDC,8BAA8B,EAC9BC,oBAAoB,EACpBC,8BAA8B,QACzB,kBAAkB;AACzB,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,OAAO,eAAeC,
|
|
1
|
+
{"version":3,"names":["CIO_PODFILE_REGEX","CIO_PODFILE_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET","CIO_PODFILE_NOTIFICATION_REGEX","CIO_CIO_TARGET_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","FileManagement","injectCIOPodfileCode","iosPath","filename","podfile","read","matches","match","targetMatch","lines","split","index","findIndex","line","test","content","slice","write","join","console","log","injectCIONotificationPodfileCode","useFrameworks","snippet","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport {\n CIO_PODFILE_REGEX,\n CIO_PODFILE_SNIPPET,\n CIO_PODFILE_NOTIFICATION_SNIPPET,\n CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET,\n CIO_PODFILE_NOTIFICATION_REGEX,\n CIO_CIO_TARGET_REGEX,\n CIO_PODFILE_POST_INSTALL_REGEX,\n} from '../constants/ios';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_REGEX);\n const targetMatch = podfile.match(CIO_CIO_TARGET_REGEX);\n\n if (!targetMatch) {\n const lines = podfile.split('\\n');\n const index = lines.findIndex((line) =>\n CIO_PODFILE_POST_INSTALL_REGEX.test(line)\n );\n let content: string[] = lines;\n if (index > -1) {\n content = [\n ...lines.slice(0, index - 1),\n !matches ? CIO_PODFILE_SNIPPET : '',\n ...lines.slice(index - 1),\n ];\n }\n\n FileManagement.write(filename, content.join('\\n'));\n } else {\n console.log('Customerio Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_NOTIFICATION_REGEX);\n\n if (!matches) {\n const snippet =\n useFrameworks === 'static'\n ? CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET\n : CIO_PODFILE_NOTIFICATION_SNIPPET;\n FileManagement.append(filename, snippet);\n }\n}\n"],"mappings":"AACA,SACEA,iBAAiB,EACjBC,mBAAmB,EACnBC,gCAAgC,EAChCC,iDAAiD,EACjDC,8BAA8B,EAC9BC,oBAAoB,EACpBC,8BAA8B,QACzB,kBAAkB;AACzB,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,OAAO,eAAeC,oBAAoBA,CAACC,OAAe,EAAE;EAC1D,MAAMC,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMJ,cAAc,CAACK,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAACd,iBAAiB,CAAC;EAChD,MAAMe,WAAW,GAAGJ,OAAO,CAACG,KAAK,CAACT,oBAAoB,CAAC;EAEvD,IAAI,CAACU,WAAW,EAAE;IAChB,MAAMC,KAAK,GAAGL,OAAO,CAACM,KAAK,CAAC,IAAI,CAAC;IACjC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IACjCd,8BAA8B,CAACe,IAAI,CAACD,IAAI,CAC1C,CAAC;IACD,IAAIE,OAAiB,GAAGN,KAAK;IAC7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;MACdI,OAAO,GAAG,CACR,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,GAAG,CAAC,CAAC,EAC5B,CAACL,OAAO,GAAGZ,mBAAmB,GAAG,EAAE,EACnC,GAAGe,KAAK,CAACO,KAAK,CAACL,KAAK,GAAG,CAAC,CAAC,CAC1B;IACH;IAEAX,cAAc,CAACiB,KAAK,CAACd,QAAQ,EAAEY,OAAO,CAACG,IAAI,CAAC,IAAI,CAAC,CAAC;EACpD,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEA,OAAO,eAAeC,gCAAgCA,CACpDnB,OAAe,EACfoB,aAA0D,EAC1D;EACA,MAAMnB,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMJ,cAAc,CAACK,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAACV,8BAA8B,CAAC;EAE7D,IAAI,CAACS,OAAO,EAAE;IACZ,MAAMiB,OAAO,GACXD,aAAa,KAAK,QAAQ,GACtB1B,iDAAiD,GACjDD,gCAAgC;IACtCK,cAAc,CAACwB,MAAM,CAACrB,QAAQ,EAAEoB,OAAO,CAAC;EAC1C;AACF"}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withCIOAndroid","withCIOIos","withCustomerIOPlugin","config","props","ios","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type { CustomerIOPluginOptions } from './types/cio-types';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n if (props.ios) {\n config = withCIOIos(config, props.ios);\n }\n\n if (props.android) {\n config = withCIOAndroid(config, props.android);\n }\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,QAAQ,kBAAkB;AAG7C;AACA,SAASC,
|
|
1
|
+
{"version":3,"names":["withCIOAndroid","withCIOIos","withCustomerIOPlugin","config","props","ios","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type { CustomerIOPluginOptions } from './types/cio-types';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n if (props.ios) {\n config = withCIOIos(config, props.ios);\n }\n\n if (props.android) {\n config = withCIOAndroid(config, props.android);\n }\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,QAAQ,kBAAkB;AAG7C;AACA,SAASC,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA,IAAIA,KAAK,CAACC,GAAG,EAAE;IACbF,MAAM,GAAGF,UAAU,CAACE,MAAM,EAAEC,KAAK,CAACC,GAAG,CAAC;EACxC;EAEA,IAAID,KAAK,CAACE,OAAO,EAAE;IACjBH,MAAM,GAAGH,cAAc,CAACG,MAAM,EAAEC,KAAK,CAACE,OAAO,CAAC;EAChD;EAEA,OAAOH,MAAM;AACf;AAEA,eAAeD,oBAAoB"}
|
|
@@ -33,7 +33,7 @@ const addDidFailToRegisterForRemoteNotificationsWithError = stringContents => {
|
|
|
33
33
|
stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET);
|
|
34
34
|
return stringContents;
|
|
35
35
|
};
|
|
36
|
-
const
|
|
36
|
+
const addDidRegisterForRemoteNotificationsWithDeviceToken = stringContents => {
|
|
37
37
|
stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET);
|
|
38
38
|
return stringContents;
|
|
39
39
|
};
|
|
@@ -45,7 +45,7 @@ const addAppdelegateHeaderModification = stringContents => {
|
|
|
45
45
|
stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_APPDELEGATEHEADER_REGEX, CIO_APPDELEGATEHEADER_SNIPPET);
|
|
46
46
|
return stringContents;
|
|
47
47
|
};
|
|
48
|
-
export const withAppDelegateModifications = configOuter => {
|
|
48
|
+
export const withAppDelegateModifications = (configOuter, props) => {
|
|
49
49
|
return withAppDelegate(configOuter, async config => {
|
|
50
50
|
let stringContents = config.modResults.contents;
|
|
51
51
|
const regex = new RegExp(`#import <${config.modRequest.projectName}-Swift.h>`);
|
|
@@ -57,10 +57,14 @@ export const withAppDelegateModifications = configOuter => {
|
|
|
57
57
|
FileManagement.write(headerPath, headerContent);
|
|
58
58
|
stringContents = addImport(stringContents, config.modRequest.projectName);
|
|
59
59
|
stringContents = addNotificationHandlerDeclaration(stringContents);
|
|
60
|
-
|
|
60
|
+
|
|
61
|
+
// any other value would be treated as true, it has to be explicitly false to disable
|
|
62
|
+
if (props.disableNotificationRegistration !== undefined && props.disableNotificationRegistration === false) {
|
|
63
|
+
stringContents = addNotificationConfiguration(stringContents);
|
|
64
|
+
}
|
|
61
65
|
stringContents = addAdditionalMethodsForPushNotifications(stringContents);
|
|
62
66
|
stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
|
|
63
|
-
stringContents =
|
|
67
|
+
stringContents = addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
|
|
64
68
|
config.modResults.contents = stringContents;
|
|
65
69
|
} else {
|
|
66
70
|
console.log('Customerio AppDelegate changes already exist. Skipping...');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","FileManagement","pushCodeSnippets","additionalMethodsForPushNotifications","join","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addDidFailToRegisterForRemoteNotificationsWithError","AddDidRegisterForRemoteNotificationsWithDeviceToken","addAdditionalMethodsForPushNotifications","addAppdelegateHeaderModification","withAppDelegateModifications","configOuter","config","modResults","contents","regex","RegExp","modRequest","projectName","headerPath","projectRoot","headerContent","read","write","console","log"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\n\nconst pushCodeSnippets = [\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n];\n\nconst additionalMethodsForPushNotifications = `${pushCodeSnippets.join(\n '\\n'\n)}\\n`; // Join newlines and ensure a newline at the end.\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n ).join('\\n');\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst AddDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addAdditionalMethodsForPushNotifications = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n additionalMethodsForPushNotifications\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET\n );\n\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<any> = (\n configOuter\n) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n stringContents = addNotificationConfiguration(stringContents);\n stringContents = addAdditionalMethodsForPushNotifications(stringContents);\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n console.log('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":"AAAA,SAAuBA,eAAe,QAAQ,sBAAsB;AACpE,SAASC,4BAA4B,QAAQ,sCAAsC;AAEnF,SACEC,gCAAgC,EAChCC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,2CAA2C,EAC3CC,8DAA8D,EAC9DC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,kCAAkC,EAClCC,iDAAiD,EACjDC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,8CAA8C,EAC9CC,0CAA0C,QACrC,0BAA0B;AACjC,SACEC,sBAAsB,EACtBC,0BAA0B,EAC1BC,wCAAwC,QACnC,gCAAgC;AACvC,SAASC,cAAc,QAAQ,iCAAiC;AAEhE,MAAMC,gBAAgB,GAAG,CACvBT,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zEA,cAAc,GACZY,mDAAmD,CAACZ,cAAc,CAAC;MACrEA,cAAc,GACZa,mDAAmD,CAACb,cAAc,CAAC;MAErEkB,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGpB,cAAc;IAC7C,CAAC,MAAM;MACL8B,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOb,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAASd,gBAAgB,CAACH,OAAe,EAAE;EACzC,OAAQ;AACV;AACA;AACA,WAAWA,OAAQ;AACnB,GAAG;AACH"}
|
|
1
|
+
{"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","FileManagement","pushCodeSnippets","additionalMethodsForPushNotifications","join","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addDidFailToRegisterForRemoteNotificationsWithError","addDidRegisterForRemoteNotificationsWithDeviceToken","addAdditionalMethodsForPushNotifications","addAppdelegateHeaderModification","withAppDelegateModifications","configOuter","props","config","modResults","contents","regex","RegExp","modRequest","projectName","headerPath","projectRoot","headerContent","read","write","disableNotificationRegistration","console","log"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nconst pushCodeSnippets = [\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n];\n\nconst additionalMethodsForPushNotifications = `${pushCodeSnippets.join(\n '\\n'\n)}\\n`; // Join newlines and ensure a newline at the end.\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n ).join('\\n');\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addAdditionalMethodsForPushNotifications = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n additionalMethodsForPushNotifications\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET\n );\n\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n\n // any other value would be treated as true, it has to be explicitly false to disable\n if (\n props.disableNotificationRegistration !== undefined &&\n props.disableNotificationRegistration === false\n ) {\n stringContents = addNotificationConfiguration(stringContents);\n }\n stringContents = addAdditionalMethodsForPushNotifications(stringContents);\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n console.log('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":"AAAA,SAAuBA,eAAe,QAAQ,sBAAsB;AACpE,SAASC,4BAA4B,QAAQ,sCAAsC;AAEnF,SACEC,gCAAgC,EAChCC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,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a,aAAa,CAAC;MAC/DjC,cAAc,CAACmC,KAAK,CAACJ,UAAU,EAAEE,aAAa,CAAC;MAE/C5B,cAAc,GAAGD,SAAS,CACxBC,cAAc,EACdmB,MAAM,CAACK,UAAU,CAACC,WACpB,CAAC;MACDzB,cAAc,GAAGU,iCAAiC,CAACV,cAAc,CAAC;;MAElE;MACA,IACEkB,KAAK,CAACa,+BAA+B,KAAKvB,SAAS,IACnDU,KAAK,CAACa,+BAA+B,KAAK,KAAK,EAC/C;QACA/B,cAAc,GAAGW,4BAA4B,CAACX,cAAc,CAAC;MAC/D;MACAA,cAAc,GAAGc,wCAAwC,CAACd,cAAc,CAAC;MACzEA,cAAc,GACZY,mDAAmD,CAACZ,cAAc,CAAC;MACrEA,cAAc,GACZa,mDAAmD,CAACb,cAAc,CAAC;MAErEmB,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGrB,cAAc;IAC7C,CAAC,MAAM;MACLgC,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOd,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAASf,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAQ;AACV;AACA;AACA,WAAWA,OAAQ;AACnB,GAAG;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAppDelegateModifications","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","props","pushNotification"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioNotificationsXcodeProject(config, props);\n config = withCioXcodeProject(config, props);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,
|
|
1
|
+
{"version":3,"names":["withAppDelegateModifications","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","props","pushNotification"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioNotificationsXcodeProject(config, props);\n config = withCioXcodeProject(config, props);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAUA,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EACA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAGJ,4BAA4B,CAACI,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAGH,gCAAgC,CAACG,MAAM,EAAEC,KAAK,CAAC;IACxDD,MAAM,GAAGF,mBAAmB,CAACE,MAAM,EAAEC,KAAK,CAAC;EAC7C;EAEA,OAAOD,MAAM;AACf"}
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import { withXcodeProject } from '@expo/config-plugins';
|
|
2
|
-
import
|
|
3
|
-
import { CIO_NOTIFICATION_TARGET_NAME, DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
|
|
2
|
+
import { CIO_NOTIFICATION_TARGET_NAME, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET, DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
|
|
4
3
|
import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
|
|
5
4
|
import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
|
|
6
5
|
import { FileManagement } from './../helpers/utils/fileManagement';
|
|
7
6
|
const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
|
|
8
7
|
const ENV_FILENAME = 'Env.swift';
|
|
9
8
|
const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
10
|
-
const addNotificationServiceExtension = async options => {
|
|
11
|
-
|
|
12
|
-
// See function withCioNotificationsXcodeProject to get where the variabes are pulled from.
|
|
13
|
-
const {
|
|
14
|
-
iosPath,
|
|
15
|
-
appName
|
|
16
|
-
} = options;
|
|
17
|
-
const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
|
|
18
|
-
const xcodeProject = xcode.project(projPath);
|
|
19
|
-
xcodeProject.parse(async function (err) {
|
|
9
|
+
const addNotificationServiceExtension = async (options, xcodeProject) => {
|
|
10
|
+
try {
|
|
20
11
|
var _options$pushNotifica;
|
|
21
|
-
if (err) {
|
|
22
|
-
throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
|
|
23
|
-
}
|
|
24
12
|
if (options.pushNotification) {
|
|
25
13
|
await addPushNotificationFile(options, xcodeProject);
|
|
26
14
|
}
|
|
27
15
|
if ((_options$pushNotifica = options.pushNotification) !== null && _options$pushNotifica !== void 0 && _options$pushNotifica.useRichPush) {
|
|
28
16
|
await addRichPushXcodeProj(options, xcodeProject);
|
|
29
17
|
}
|
|
30
|
-
|
|
31
|
-
})
|
|
18
|
+
return xcodeProject;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(error);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
32
23
|
};
|
|
33
24
|
export const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
34
25
|
return withXcodeProject(configOuter, async config => {
|
|
@@ -64,6 +55,7 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
|
64
55
|
throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js or app.json');
|
|
65
56
|
}
|
|
66
57
|
const options = {
|
|
58
|
+
...props,
|
|
67
59
|
appleTeamId,
|
|
68
60
|
bundleIdentifier,
|
|
69
61
|
bundleShortVersion,
|
|
@@ -74,7 +66,10 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
|
74
66
|
iosDeploymentTarget,
|
|
75
67
|
pushNotification
|
|
76
68
|
};
|
|
77
|
-
await addNotificationServiceExtension(options);
|
|
69
|
+
const modifiedProjectFile = await addNotificationServiceExtension(options, config.modResults);
|
|
70
|
+
if (modifiedProjectFile) {
|
|
71
|
+
config.modResults = modifiedProjectFile;
|
|
72
|
+
}
|
|
78
73
|
return config;
|
|
79
74
|
});
|
|
80
75
|
};
|
|
@@ -89,6 +84,13 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
89
84
|
useFrameworks
|
|
90
85
|
} = options;
|
|
91
86
|
await injectCIONotificationPodfileCode(iosPath, useFrameworks);
|
|
87
|
+
|
|
88
|
+
// Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
|
|
89
|
+
// If true then skip creating a new group to avoid duplicate folders
|
|
90
|
+
if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
|
|
91
|
+
console.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
92
94
|
const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;
|
|
93
95
|
FileManagement.mkdir(nsePath, {
|
|
94
96
|
recursive: true
|
|
@@ -116,7 +118,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
116
118
|
// files / folder appear in the file explorer in Xcode.
|
|
117
119
|
const groups = xcodeProject.hash.project.objects['PBXGroup'];
|
|
118
120
|
Object.keys(groups).forEach(key => {
|
|
119
|
-
if (groups[key].name === undefined) {
|
|
121
|
+
if (groups[key].name === undefined && groups[key].path === undefined) {
|
|
120
122
|
xcodeProject.addToPbxGroup(extGroup.uuid, key);
|
|
121
123
|
}
|
|
122
124
|
});
|
|
@@ -186,14 +188,19 @@ const updateNseEnv = (options, envFileName) => {
|
|
|
186
188
|
envFileContent = replaceCodeByRegex(envFileContent, API_KEY_RE, (_options$pushNotifica8 = options.pushNotification) === null || _options$pushNotifica8 === void 0 ? void 0 : (_options$pushNotifica9 = _options$pushNotifica8.env) === null || _options$pushNotifica9 === void 0 ? void 0 : _options$pushNotifica9.apiKey);
|
|
187
189
|
}
|
|
188
190
|
if ((_options$pushNotifica10 = options.pushNotification) !== null && _options$pushNotifica10 !== void 0 && (_options$pushNotifica11 = _options$pushNotifica10.env) !== null && _options$pushNotifica11 !== void 0 && _options$pushNotifica11.region) {
|
|
189
|
-
var _options$pushNotifica12, _options$pushNotifica13, _options$pushNotifica14
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
191
|
+
var _options$pushNotifica12, _options$pushNotifica13, _options$pushNotifica14;
|
|
192
|
+
const regionMap = {
|
|
193
|
+
us: 'Region.US',
|
|
194
|
+
eu: 'Region.EU'
|
|
195
|
+
};
|
|
196
|
+
const region = (_options$pushNotifica12 = options.pushNotification) === null || _options$pushNotifica12 === void 0 ? void 0 : (_options$pushNotifica13 = _options$pushNotifica12.env) === null || _options$pushNotifica13 === void 0 ? void 0 : (_options$pushNotifica14 = _options$pushNotifica13.region) === null || _options$pushNotifica14 === void 0 ? void 0 : _options$pushNotifica14.toLowerCase();
|
|
197
|
+
const mappedRegion = regionMap[region] || '';
|
|
198
|
+
if (!mappedRegion) {
|
|
199
|
+
var _options$pushNotifica15, _options$pushNotifica16;
|
|
200
|
+
console.warn(`${(_options$pushNotifica15 = options.pushNotification) === null || _options$pushNotifica15 === void 0 ? void 0 : (_options$pushNotifica16 = _options$pushNotifica15.env) === null || _options$pushNotifica16 === void 0 ? void 0 : _options$pushNotifica16.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`);
|
|
201
|
+
} else {
|
|
202
|
+
envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);
|
|
195
203
|
}
|
|
196
|
-
envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, region);
|
|
197
204
|
}
|
|
198
205
|
FileManagement.writeFile(envFileName, envFileContent);
|
|
199
206
|
};
|
|
@@ -205,15 +212,20 @@ async function addPushNotificationFile(options, xcodeProject) {
|
|
|
205
212
|
const file = 'PushService.swift';
|
|
206
213
|
const appPath = `${iosPath}/${appName}`;
|
|
207
214
|
const getTargetFile = filename => `${appPath}/${filename}`;
|
|
215
|
+
const targetFile = getTargetFile(file);
|
|
216
|
+
|
|
217
|
+
// Check whether {file} exists in the project. If false, then add the file
|
|
218
|
+
// If {file} exists then skip and return
|
|
208
219
|
if (!FileManagement.exists(getTargetFile(file))) {
|
|
209
220
|
FileManagement.mkdir(appPath, {
|
|
210
221
|
recursive: true
|
|
211
222
|
});
|
|
212
|
-
const targetFile = getTargetFile(file);
|
|
213
223
|
FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
|
|
214
224
|
} else {
|
|
215
225
|
console.log(`${getTargetFile(file)} already exists. Skipping...`);
|
|
226
|
+
return;
|
|
216
227
|
}
|
|
228
|
+
updatePushFile(options, targetFile);
|
|
217
229
|
const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');
|
|
218
230
|
const classesKey = xcodeProject.findPBXGroupKey({
|
|
219
231
|
name: `${appName}`
|
|
@@ -221,4 +233,14 @@ async function addPushNotificationFile(options, xcodeProject) {
|
|
|
221
233
|
xcodeProject.addToPbxGroup(group, classesKey);
|
|
222
234
|
xcodeProject.addSourceFile(`${appName}/${file}`, null, group);
|
|
223
235
|
}
|
|
236
|
+
const updatePushFile = (options, envFileName) => {
|
|
237
|
+
const REGISTER_RE = /\{\{REGISTER_SNIPPET\}\}/;
|
|
238
|
+
let envFileContent = FileManagement.readFile(envFileName);
|
|
239
|
+
let snippet = '';
|
|
240
|
+
if (options.disableNotificationRegistration !== undefined && options.disableNotificationRegistration === false) {
|
|
241
|
+
snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;
|
|
242
|
+
}
|
|
243
|
+
envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);
|
|
244
|
+
FileManagement.writeFile(envFileName, envFileContent);
|
|
245
|
+
};
|
|
224
246
|
//# sourceMappingURL=withNotificationsXcodeProject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withXcodeProject","xcode","CIO_NOTIFICATION_TARGET_NAME","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","replaceCodeByRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","iosPath","appName","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","nsePath","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","extGroup","addPbxGroup","groups","hash","objects","Object","keys","key","name","addToPbxGroup","uuid","projObjects","pbxTargetByName","console","warn","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","envFileName","SITE_ID_RE","API_KEY_RE","REGION_RE","envFileContent","env","siteId","apiKey","region","file","appPath","exists","log","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n // iosPath and appName are predefined from Expo config.\n // See function withCioNotificationsXcodeProject to get where the variabes are pulled from.\n const { iosPath, appName } = options;\n\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n if (options.pushNotification) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n\n FileManagement.writeFile(projPath, xcodeProject.writeSync());\n });\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const {\n appleTeamId,\n iosDeploymentTarget,\n pushNotification,\n useFrameworks,\n } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n pushNotification,\n };\n\n await addNotificationServiceExtension(options);\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks);\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '13.0';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const SITE_ID_RE = /\\{\\{SITE_ID\\}\\}/;\n const API_KEY_RE = /\\{\\{API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.siteId) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n SITE_ID_RE,\n options.pushNotification?.env?.siteId\n );\n }\n\n if (options.pushNotification?.env?.apiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n API_KEY_RE,\n options.pushNotification?.env?.apiKey\n );\n }\n\n if (options.pushNotification?.env?.region) {\n let region = '';\n if (options.pushNotification?.env?.region === 'us') {\n region = 'Region.US';\n } else if (options.pushNotification?.env?.region === 'eu') {\n region = 'Region.EU';\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, region);\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n const { iosPath, appName } = options;\n const file = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n const targetFile = getTargetFile(file);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} already exists. Skipping...`);\n }\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${file}`, null, group);\n}\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,4BAA4B,EAC5BC,sBAAsB,EACtBC,2BAA2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AAc,CAACwC,KAAK,CAACsD,OAAO,EAAE;MAC5BrD,SAAS,EAAE;IACb,CAAC,CAAC;IAEF,MAAMK,UAAU,GAAGH,aAAa,CAACkD,IAAI,CAAC;IACtC7F,cAAc,CAAC+C,QAAQ,CACpB,GAAElD,2BAA4B,IAAGgG,IAAK,EAAC,EACxC/C,UAAU,CACX;EACH,CAAC,MAAM;IACLkB,OAAO,CAACgC,GAAG,CAAE,GAAErD,aAAa,CAACkD,IAAI,CAAE,8BAA6B,CAAC;EACnE;EAEA,MAAMI,KAAK,GAAGxF,YAAY,CAACyF,cAAc,CAAC,yBAAyB,CAAC;EACpE,MAAMC,UAAU,GAAG1F,YAAY,CAAC2F,eAAe,CAAC;IAAEzC,IAAI,EAAG,GAAEpD,OAAQ;EAAE,CAAC,CAAC;EACvEE,YAAY,CAACmD,aAAa,CAACqC,KAAK,EAAEE,UAAU,CAAC;EAE7C1F,YAAY,CAAC4F,aAAa,CAAE,GAAE9F,OAAQ,IAAGsF,IAAK,EAAC,EAAE,IAAI,EAAEI,KAAK,CAAC;AAC/D"}
|
|
1
|
+
{"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","replaceCodeByRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","console","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","pbxTargetByName","warn","nsePath","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","extGroup","addPbxGroup","groups","hash","project","objects","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","writeFile","envFileName","_options$pushNotifica2","_options$pushNotifica3","_options$pushNotifica6","_options$pushNotifica7","_options$pushNotifica10","_options$pushNotifica11","SITE_ID_RE","API_KEY_RE","REGION_RE","envFileContent","env","siteId","_options$pushNotifica4","_options$pushNotifica5","apiKey","_options$pushNotifica8","_options$pushNotifica9","region","_options$pushNotifica12","_options$pushNotifica13","_options$pushNotifica14","regionMap","us","eu","toLowerCase","mappedRegion","_options$pushNotifica15","_options$pushNotifica16","file","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","REGISTER_RE","snippet","disableNotificationRegistration"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import {\n ConfigPlugin,\n XcodeProject,\n withXcodeProject,\n} from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) => {\n try {\n if (options.pushNotification) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: any) {\n console.error(error);\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const {\n appleTeamId,\n iosDeploymentTarget,\n pushNotification,\n useFrameworks,\n } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n pushNotification,\n };\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '13.0';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const SITE_ID_RE = /\\{\\{SITE_ID\\}\\}/;\n const API_KEY_RE = /\\{\\{API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.siteId) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n SITE_ID_RE,\n options.pushNotification?.env?.siteId\n );\n }\n\n if (options.pushNotification?.env?.apiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n API_KEY_RE,\n options.pushNotification?.env?.apiKey\n );\n }\n\n if (options.pushNotification?.env?.region) {\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const region = options.pushNotification?.env?.region?.toLowerCase();\n const mappedRegion = (regionMap as any)[region] || '';\n if (!mappedRegion) {\n console.warn(\n `${options.pushNotification?.env?.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`\n );\n } else {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n REGION_RE,\n mappedRegion\n );\n }\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n const { iosPath, appName } = options;\n const file = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(file);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${file}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n let snippet = '';\n if (\n options.disableNotificationRegistration !== undefined &&\n options.disableNotificationRegistration === false\n ) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AAAA,SAGEA,gBAAgB,QACX,sBAAsB;AAE7B,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,cAAc,GAAI,GAAEP,4BAA6B,aAAY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C;EACpE,MAAMC,UAAU,GAAGjH,YAAY,CAACkH,eAAe,CAAC;IAAE7D,IAAI,EAAG,GAAE1B,OAAQ;EAAE,CAAC,CAAC;EACvE3B,YAAY,CAACuD,aAAa,CAACwD,KAAK,EAAEE,UAAU,CAAC;EAE7CjH,YAAY,CAACmH,aAAa,CAAE,GAAExF,OAAQ,IAAG+E,IAAK,EAAC,EAAE,IAAI,EAAEK,KAAK,CAAC;AAC/D;AAEA,MAAMD,cAAc,GAAGA,CACrB/G,OAAmC,EACnC8E,WAAmB,KAChB;EACH,MAAMuC,WAAW,GAAG,0BAA0B;EAE9C,IAAI7B,cAAc,GAAG7F,cAAc,CAACiF,QAAQ,CAACE,WAAW,CAAC;EAEzD,IAAIwC,OAAO,GAAG,EAAE;EAChB,IACEtH,OAAO,CAACuH,+BAA+B,KAAKnG,SAAS,IACrDpB,OAAO,CAACuH,+BAA+B,KAAK,KAAK,EACjD;IACAD,OAAO,GAAGhI,qCAAqC;EACjD;EAEAkG,cAAc,GAAG/F,kBAAkB,CAAC+F,cAAc,EAAE6B,WAAW,EAAEC,OAAO,CAAC;EAEzE3H,cAAc,CAACkF,SAAS,CAACC,WAAW,EAAEU,cAAc,CAAC;AACvD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withXcodeProject","injectCIOPodfileCode","withCioXcodeProject","config","cioProps","props","options","iosPath","modRequest","platformProjectRoot","bundleIdentifier","ios","devTeam","bundleVersion","buildNumber","bundleShortVersion","version","iosDeploymentTarget"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\n\nimport { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nexport const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const options: CustomerIOPluginOptionsIOS = {\n iosPath: props.modRequest.platformProjectRoot,\n bundleIdentifier: props.ios?.bundleIdentifier,\n devTeam: cioProps?.devTeam,\n bundleVersion: props.ios?.buildNumber,\n bundleShortVersion: props?.version,\n iosDeploymentTarget: cioProps?.iosDeploymentTarget,\n };\n const { iosPath } = options;\n\n await injectCIOPodfileCode(iosPath);\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AAErE,SAASC,oBAAoB,QAAQ,uCAAuC;AAG5E,OAAO,MAAMC,mBAA6D,
|
|
1
|
+
{"version":3,"names":["withXcodeProject","injectCIOPodfileCode","withCioXcodeProject","config","cioProps","props","_props$ios","_props$ios2","options","iosPath","modRequest","platformProjectRoot","bundleIdentifier","ios","devTeam","bundleVersion","buildNumber","bundleShortVersion","version","iosDeploymentTarget"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\n\nimport { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nexport const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const options: CustomerIOPluginOptionsIOS = {\n iosPath: props.modRequest.platformProjectRoot,\n bundleIdentifier: props.ios?.bundleIdentifier,\n devTeam: cioProps?.devTeam,\n bundleVersion: props.ios?.buildNumber,\n bundleShortVersion: props?.version,\n iosDeploymentTarget: cioProps?.iosDeploymentTarget,\n };\n const { iosPath } = options;\n\n await injectCIOPodfileCode(iosPath);\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AAErE,SAASC,oBAAoB,QAAQ,uCAAuC;AAG5E,OAAO,MAAMC,mBAA6D,GAAGA,CAC3EC,MAAM,EACNC,QAAQ,KACL;EACH,OAAOJ,gBAAgB,CAACG,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA,IAAAC,UAAA,EAAAC,WAAA;IAC/C,MAAMC,OAAmC,GAAG;MAC1CC,OAAO,EAAEJ,KAAK,CAACK,UAAU,CAACC,mBAAmB;MAC7CC,gBAAgB,GAAAN,UAAA,GAAED,KAAK,CAACQ,GAAG,cAAAP,UAAA,uBAATA,UAAA,CAAWM,gBAAgB;MAC7CE,OAAO,EAAEV,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEU,OAAO;MAC1BC,aAAa,GAAAR,WAAA,GAAEF,KAAK,CAACQ,GAAG,cAAAN,WAAA,uBAATA,WAAA,CAAWS,WAAW;MACrCC,kBAAkB,EAAEZ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEa,OAAO;MAClCC,mBAAmB,EAAEf,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEe;IACjC,CAAC;IACD,MAAM;MAAEV;IAAQ,CAAC,GAAGD,OAAO;IAE3B,MAAMP,oBAAoB,CAACQ,OAAO,CAAC;IAEnC,OAAOJ,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ph","require","runPostInstall","error"],"sources":["postInstall.js"],"sourcesContent":["try {\n const ph = require('./postInstallHelper');\n\n ph.runPostInstall();\n} catch (error) {}\n"],"mappings":"AAAA,IAAI;EACF,MAAMA,EAAE,GAAGC,OAAO,CAAC,qBAAqB,CAAC;EAEzCD,EAAE,CAACE,cAAc,
|
|
1
|
+
{"version":3,"names":["ph","require","runPostInstall","error"],"sources":["postInstall.js"],"sourcesContent":["try {\n const ph = require('./postInstallHelper');\n\n ph.runPostInstall();\n} catch (error) {}\n"],"mappings":"AAAA,IAAI;EACF,MAAMA,EAAE,GAAGC,OAAO,CAAC,qBAAqB,CAAC;EAEzCD,EAAE,CAACE,cAAc,CAAC,CAAC;AACrB,CAAC,CAAC,OAAOC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fs","require","runPostInstall","rnPjsonFile","__dirname","expoPjsonFile","existsSync","rnPJson","readFileSync","expoPjson","rnPackage","JSON","parse","expoVersion","version","writeFileSync","stringify","error","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\n\nfunction runPostInstall() {\n // react native SDK package.json path\n const rnPjsonFile = `${__dirname}/../../customerio-reactnative/package.json`;\n const expoPjsonFile = `${__dirname}/../package.json`;\n try {\n // if react native SDK is installed\n if (fs.existsSync(rnPjsonFile)) {\n const rnPJson = fs.readFileSync(rnPjsonFile, 'utf8');\n expoPjson = require(expoPjsonFile);\n\n const rnPackage = JSON.parse(rnPJson);\n rnPackage.expoVersion = expoPjson.version;\n\n\n fs.writeFileSync(rnPjsonFile, JSON.stringify(rnPackage, null, 2));\n }\n } catch (error) {}\n}\n\nexports.runPostInstall = runPostInstall;"],"mappings":"AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExB,SAASC,
|
|
1
|
+
{"version":3,"names":["fs","require","runPostInstall","rnPjsonFile","__dirname","expoPjsonFile","existsSync","rnPJson","readFileSync","expoPjson","rnPackage","JSON","parse","expoVersion","version","writeFileSync","stringify","error","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\n\nfunction runPostInstall() {\n // react native SDK package.json path\n const rnPjsonFile = `${__dirname}/../../customerio-reactnative/package.json`;\n const expoPjsonFile = `${__dirname}/../package.json`;\n try {\n // if react native SDK is installed\n if (fs.existsSync(rnPjsonFile)) {\n const rnPJson = fs.readFileSync(rnPjsonFile, 'utf8');\n expoPjson = require(expoPjsonFile);\n\n const rnPackage = JSON.parse(rnPJson);\n rnPackage.expoVersion = expoPjson.version;\n\n\n fs.writeFileSync(rnPjsonFile, JSON.stringify(rnPackage, null, 2));\n }\n } catch (error) {}\n}\n\nexports.runPostInstall = runPostInstall;"],"mappings":"AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExB,SAASC,cAAcA,CAAA,EAAG;EACxB;EACA,MAAMC,WAAW,GAAI,GAAEC,SAAU,4CAA2C;EAC5E,MAAMC,aAAa,GAAI,GAAED,SAAU,kBAAiB;EACpD,IAAI;IACF;IACA,IAAIJ,EAAE,CAACM,UAAU,CAACH,WAAW,CAAC,EAAE;MAC9B,MAAMI,OAAO,GAAGP,EAAE,CAACQ,YAAY,CAACL,WAAW,EAAE,MAAM,CAAC;MACpDM,SAAS,GAAGR,OAAO,CAACI,aAAa,CAAC;MAElC,MAAMK,SAAS,GAAGC,IAAI,CAACC,KAAK,CAACL,OAAO,CAAC;MACrCG,SAAS,CAACG,WAAW,GAAGJ,SAAS,CAACK,OAAO;MAGzCd,EAAE,CAACe,aAAa,CAACZ,WAAW,EAAEQ,IAAI,CAACK,SAAS,CAACN,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACnE;EACF,CAAC,CAAC,OAAOO,KAAK,EAAE,CAAC;AACnB;AAEAC,OAAO,CAAChB,cAAc,GAAGA,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n useRichPush: boolean;\n env: {\n siteId: string;\n apiKey: string;\n region: string;\n };\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n disableNotificationRegistration?: boolean;\n useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n useRichPush: boolean;\n env: {\n siteId: string;\n apiKey: string;\n region: string;\n };\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const LOCAL_PATH_TO_CIO_NSE_FILES
|
|
1
|
+
export declare const LOCAL_PATH_TO_CIO_NSE_FILES: any;
|
|
2
2
|
export declare const IOS_DEPLOYMENT_TARGET = "13.0";
|
|
3
|
-
export declare const CIO_SDK_VERSION = "~> 2.0
|
|
3
|
+
export declare const CIO_SDK_VERSION = "'~> 2.0'";
|
|
4
4
|
export declare const CIO_PODFILE_REGEX: RegExp;
|
|
5
5
|
export declare const CIO_CIO_TARGET_REGEX: RegExp;
|
|
6
6
|
export declare const CIO_PODFILE_NOTIFICATION_REGEX: RegExp;
|
|
@@ -20,11 +20,12 @@ export declare const CIO_TARGET_NAME = "CustomerIOSDK";
|
|
|
20
20
|
export declare const CIO_NOTIFICATION_TARGET_NAME = "NotificationService";
|
|
21
21
|
export declare const CIO_APPDELEGATEHEADER_SNIPPET = "\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n";
|
|
22
22
|
export declare const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = "\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n";
|
|
23
|
-
export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = "\n [pnHandlerObj application:application error:error];\n";
|
|
24
|
-
export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = "\n return [pnHandlerObj application:application deviceToken:deviceToken];\n";
|
|
23
|
+
export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = "\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n";
|
|
24
|
+
export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = "\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n";
|
|
25
25
|
export declare const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = "\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n";
|
|
26
26
|
export declare const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = "\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}";
|
|
27
27
|
export declare const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = "\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}";
|
|
28
28
|
export declare const CIO_PODFILE_SNIPPET: string;
|
|
29
29
|
export declare const CIO_PODFILE_NOTIFICATION_SNIPPET: string;
|
|
30
30
|
export declare const CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET: string;
|
|
31
|
+
export declare const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = "\n@objc(registerPushNotification:)\n public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {\n\n let center = UNUserNotificationCenter.current()\n center.delegate = notificationDelegate\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
-
|
|
2
|
+
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
3
|
+
export declare const withAppDelegateModifications: ConfigPlugin<CustomerIOPluginOptionsIOS>;
|
|
@@ -11,6 +11,7 @@ export type CustomerIOPluginOptionsIOS = {
|
|
|
11
11
|
iosDeploymentTarget?: string;
|
|
12
12
|
appleTeamId?: string;
|
|
13
13
|
appName?: string;
|
|
14
|
+
disableNotificationRegistration?: boolean;
|
|
14
15
|
useFrameworks?: 'static' | 'dynamic';
|
|
15
16
|
pushNotification?: {
|
|
16
17
|
useRichPush: boolean;
|
|
@@ -24,6 +25,7 @@ export type CustomerIOPluginOptionsIOS = {
|
|
|
24
25
|
export type CustomerIOPluginOptionsAndroid = {
|
|
25
26
|
androidPath: string;
|
|
26
27
|
googleServicesFile?: string;
|
|
28
|
+
setHighPriorityPushHandler?: boolean;
|
|
27
29
|
};
|
|
28
30
|
export type CustomerIOPluginOptions = {
|
|
29
31
|
android: CustomerIOPluginOptionsAndroid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-expo-plugin",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"description": "Expo config plugin for the Customer IO React Native SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"registry": "https://registry.npmjs.org/"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"customerio-reactnative": "^2.0.0
|
|
43
|
+
"customerio-reactnative": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@expo/config-plugins": "^4.1.4",
|
|
@@ -111,5 +111,8 @@
|
|
|
111
111
|
}
|
|
112
112
|
]
|
|
113
113
|
]
|
|
114
|
+
},
|
|
115
|
+
"dependencies": {
|
|
116
|
+
"find-package-json": "^1.2.0"
|
|
114
117
|
}
|
|
115
118
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ConfigPlugin, withAndroidManifest } from '@expo/config-plugins';
|
|
2
|
+
import type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';
|
|
3
|
+
|
|
4
|
+
import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
|
|
5
|
+
|
|
6
|
+
export const withAndroidManifestUpdates: ConfigPlugin<
|
|
7
|
+
CustomerIOPluginOptionsAndroid
|
|
8
|
+
> = (configOuter) => {
|
|
9
|
+
return withAndroidManifest(configOuter, (props) => {
|
|
10
|
+
const application = props.modResults.manifest
|
|
11
|
+
.application as ManifestApplication[];
|
|
12
|
+
const customerIOMessagingpush =
|
|
13
|
+
'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
|
|
14
|
+
|
|
15
|
+
if (!application[0]['service']) {
|
|
16
|
+
application[0]['service'] = [];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const hasService = application[0]['service'].some(
|
|
20
|
+
(service) => service['$']['android:name'] === customerIOMessagingpush
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if (!hasService) {
|
|
24
|
+
application[0]['service'].push({
|
|
25
|
+
'$': {
|
|
26
|
+
'android:name': customerIOMessagingpush,
|
|
27
|
+
'android:exported': 'false',
|
|
28
|
+
},
|
|
29
|
+
'intent-filter': [
|
|
30
|
+
{
|
|
31
|
+
action: [
|
|
32
|
+
{
|
|
33
|
+
$: {
|
|
34
|
+
'android:name': 'com.google.firebase.MESSAGING_EVENT',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
console.log(
|
|
42
|
+
'Successfully set CustomerIO push handler as priority in AndroidManifest.xml'
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
props.modResults.manifest.application = application;
|
|
47
|
+
return props;
|
|
48
|
+
});
|
|
49
|
+
};
|