onesignal-expo-plugin
Advanced tools
Comparing version 1.0.0-beta10 to 1.0.0-beta11
@@ -37,2 +37,3 @@ "use strict"; | ||
const OneSignalLog_1 = require("../support/OneSignalLog"); | ||
const FileManager_1 = require("../support/FileManager"); | ||
/** | ||
@@ -83,4 +84,4 @@ * Add 'app-environment' record with current environment to '<project-name>.entitlements' file | ||
} | ||
let modResultsArray = newConfig.modResults[APP_GROUP_KEY]; | ||
let entitlement = `group.${((_a = newConfig === null || newConfig === void 0 ? void 0 : newConfig.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier) || ""}.onesignal`; | ||
const modResultsArray = newConfig.modResults[APP_GROUP_KEY]; | ||
const entitlement = `group.${((_a = newConfig === null || newConfig === void 0 ? void 0 : newConfig.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier) || ""}.onesignal`; | ||
if (modResultsArray.indexOf(entitlement) !== -1) { | ||
@@ -118,16 +119,13 @@ return newConfig; | ||
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget } = options; | ||
(0, updatePodfile_1.updatePodfile)(iosPath); | ||
NseUpdaterManager_1.default.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`); | ||
NseUpdaterManager_1.default.updateNSEBundleVersion(bundleVersion !== null && bundleVersion !== void 0 ? bundleVersion : iosConstants_1.DEFAULT_BUNDLE_VERSION); | ||
NseUpdaterManager_1.default.updateNSEBundleShortVersion(bundleShortVersion !== null && bundleShortVersion !== void 0 ? bundleShortVersion : iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION); | ||
// not awaiting in order to not block main thread | ||
(0, updatePodfile_1.updatePodfile)(iosPath).catch(err => { OneSignalLog_1.OneSignalLog.error(err); }); | ||
const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`; | ||
const targetName = "OneSignalNotificationServiceExtension"; | ||
const extFiles = [ | ||
"NotificationService.h", | ||
"NotificationService.m", | ||
`${targetName}.entitlements`, | ||
`${targetName}-Info.plist` | ||
`${iosConstants_1.NSE_TARGET_NAME}.entitlements`, | ||
`${iosConstants_1.NSE_TARGET_NAME}-Info.plist` | ||
]; | ||
const xcodeProject = xcode_1.default.project(projPath); | ||
xcodeProject.parse(function (err) { | ||
xcodeProject.parse(async function (err) { | ||
if (err) { | ||
@@ -137,19 +135,19 @@ OneSignalLog_1.OneSignalLog.log(`Error parsing iOS project: ${JSON.stringify(err)}`); | ||
} | ||
// Copy in the extension files | ||
fs.mkdirSync(`${iosPath}/${targetName}`, { recursive: true }); | ||
extFiles.forEach(function (extFile) { | ||
let targetFile = `${iosPath}/${targetName}/${extFile}`; | ||
try { | ||
fs.createReadStream(`${sourceDir}${extFile}`).pipe(fs.createWriteStream(targetFile)); | ||
} | ||
catch (err) { | ||
OneSignalLog_1.OneSignalLog.log(err); | ||
} | ||
}); | ||
const projObjects = xcodeProject.hash.project.objects; | ||
/* COPY OVER EXTENSION FILES */ | ||
fs.mkdirSync(`${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`, { recursive: true }); | ||
for (let i = 0; i < extFiles.length; i++) { | ||
const extFile = extFiles[i]; | ||
const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${extFile}`; | ||
await FileManager_1.FileManager.copyFile(`${sourceDir}${extFile}`, targetFile); | ||
} | ||
/* MODIFY COPIED EXTENSION FILES */ | ||
const nseUpdater = new NseUpdaterManager_1.default(iosPath); | ||
await nseUpdater.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`); | ||
await nseUpdater.updateNSEBundleVersion(bundleVersion !== null && bundleVersion !== void 0 ? bundleVersion : iosConstants_1.DEFAULT_BUNDLE_VERSION); | ||
await nseUpdater.updateNSEBundleShortVersion(bundleShortVersion !== null && bundleShortVersion !== void 0 ? bundleShortVersion : iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION); | ||
// Create new PBXGroup for the extension | ||
let extGroup = xcodeProject.addPbxGroup(extFiles, targetName, targetName); | ||
const extGroup = xcodeProject.addPbxGroup(extFiles, iosConstants_1.NSE_TARGET_NAME, iosConstants_1.NSE_TARGET_NAME); | ||
// Add the new PBXGroup to the top level group. This makes the | ||
// files / folder appear in the file explorer in Xcode. | ||
let groups = xcodeProject.hash.project.objects["PBXGroup"]; | ||
const groups = xcodeProject.hash.project.objects["PBXGroup"]; | ||
Object.keys(groups).forEach(function (key) { | ||
@@ -164,6 +162,7 @@ if (groups[key].name === undefined) { | ||
// - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860 | ||
const projObjects = xcodeProject.hash.project.objects; | ||
projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {}; | ||
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {}; | ||
if (!!xcodeProject.pbxTargetByName(targetName)) { | ||
OneSignalLog_1.OneSignalLog.log(`${targetName} already exists in project. Skipping...`); | ||
if (!!xcodeProject.pbxTargetByName(iosConstants_1.NSE_TARGET_NAME)) { | ||
OneSignalLog_1.OneSignalLog.log(`${iosConstants_1.NSE_TARGET_NAME} already exists in project. Skipping...`); | ||
return; | ||
@@ -173,3 +172,3 @@ } | ||
// This adds PBXTargetDependency and PBXContainerItemProxy for you | ||
const nseTarget = xcodeProject.addTarget(targetName, "app_extension", targetName, `${bundleIdentifier}.${targetName}`); | ||
const nseTarget = xcodeProject.addTarget(iosConstants_1.NSE_TARGET_NAME, "app_extension", iosConstants_1.NSE_TARGET_NAME, `${bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`); | ||
// Add build phases to the new target | ||
@@ -181,11 +180,11 @@ xcodeProject.addBuildPhase(["NotificationService.m"], "PBXSourcesBuildPhase", "Sources", nseTarget.uuid); | ||
// However, can be more | ||
let configurations = xcodeProject.pbxXCBuildConfigurationSection(); | ||
for (let key in configurations) { | ||
const configurations = xcodeProject.pbxXCBuildConfigurationSection(); | ||
for (const key in configurations) { | ||
if (typeof configurations[key].buildSettings !== "undefined" && | ||
configurations[key].buildSettings.PRODUCT_NAME == `"${targetName}"`) { | ||
let buildSettingsObj = configurations[key].buildSettings; | ||
configurations[key].buildSettings.PRODUCT_NAME == `"${iosConstants_1.NSE_TARGET_NAME}"`) { | ||
const buildSettingsObj = configurations[key].buildSettings; | ||
buildSettingsObj.DEVELOPMENT_TEAM = devTeam; | ||
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iPhoneDeploymentTarget !== null && iPhoneDeploymentTarget !== void 0 ? iPhoneDeploymentTarget : iosConstants_1.IPHONEOS_DEPLOYMENT_TARGET; | ||
buildSettingsObj.TARGETED_DEVICE_FAMILY = iosConstants_1.TARGETED_DEVICE_FAMILY; | ||
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${targetName}/${targetName}.entitlements`; | ||
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_TARGET_NAME}.entitlements`; | ||
buildSettingsObj.CODE_SIGN_STYLE = "Automatic"; | ||
@@ -192,0 +191,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.DEFAULT_BUNDLE_VERSION = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.NSE_PODFILE_REGEX = exports.NSE_PODFILE_SNIPPET = exports.TARGETED_DEVICE_FAMILY = exports.IPHONEOS_DEPLOYMENT_TARGET = void 0; | ||
exports.NSE_TARGET_NAME = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.DEFAULT_BUNDLE_VERSION = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.NSE_PODFILE_REGEX = exports.NSE_PODFILE_SNIPPET = exports.TARGETED_DEVICE_FAMILY = exports.IPHONEOS_DEPLOYMENT_TARGET = void 0; | ||
exports.IPHONEOS_DEPLOYMENT_TARGET = "11.0"; | ||
exports.TARGETED_DEVICE_FAMILY = `\"1,2\"`; | ||
exports.TARGETED_DEVICE_FAMILY = `"1,2"`; | ||
exports.NSE_PODFILE_SNIPPET = ` | ||
@@ -16,1 +16,2 @@ target 'OneSignalNotificationServiceExtension' do | ||
exports.DEFAULT_BUNDLE_SHORT_VERSION = '1.0'; | ||
exports.NSE_TARGET_NAME = "OneSignalNotificationServiceExtension"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs = __importStar(require("fs")); | ||
const FileManager_1 = require("./FileManager"); | ||
const iosConstants_1 = require("./iosConstants"); | ||
const OneSignalLog_1 = require("./OneSignalLog"); | ||
const ReaderManager_1 = require("./ReaderManager"); | ||
const entitlementsFilePath = `${__dirname}/serviceExtensionFiles/OneSignalNotificationServiceExtension.entitlements`; | ||
const plistFilePath = `${__dirname}/serviceExtensionFiles/OneSignalNotificationServiceExtension-Info.plist`; | ||
const logIfError = (err) => { | ||
if (err) { | ||
OneSignalLog_1.OneSignalLog.error("Error updating OneSignal NSE Entitlement File."); | ||
// project `ios/OneSignalNotificationServiceExtension` directory | ||
const entitlementsFileName = `OneSignalNotificationServiceExtension.entitlements`; | ||
const plistFileName = `OneSignalNotificationServiceExtension-Info.plist`; | ||
class NseUpdaterManager { | ||
constructor(iosPath) { | ||
this.nsePath = ''; | ||
this.nsePath = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`; | ||
} | ||
}; | ||
class NseUpdaterManager { | ||
static async updateNSEEntitlements(groupIdentifier) { | ||
let entitlementsFile = await ReaderManager_1.ReaderManager.readFile(entitlementsFilePath); | ||
async updateNSEEntitlements(groupIdentifier) { | ||
const entitlementsFilePath = `${this.nsePath}/${entitlementsFileName}`; | ||
let entitlementsFile = await FileManager_1.FileManager.readFile(entitlementsFilePath); | ||
entitlementsFile = entitlementsFile.replace(iosConstants_1.GROUP_IDENTIFIER_TEMPLATE_REGEX, groupIdentifier); | ||
fs.writeFile(entitlementsFilePath, entitlementsFile, 'utf-8', (err) => { | ||
logIfError(err); | ||
}); | ||
await FileManager_1.FileManager.writeFile(entitlementsFilePath, entitlementsFile); | ||
} | ||
static async updateNSEBundleVersion(version) { | ||
let plistFile = await ReaderManager_1.ReaderManager.readFile(plistFilePath); | ||
async updateNSEBundleVersion(version) { | ||
const plistFilePath = `${this.nsePath}/${plistFileName}`; | ||
let plistFile = await FileManager_1.FileManager.readFile(plistFilePath); | ||
plistFile = plistFile.replace(iosConstants_1.BUNDLE_VERSION_TEMPLATE_REGEX, version); | ||
fs.writeFile(plistFilePath, plistFile, 'utf-8', err => { | ||
logIfError(err); | ||
}); | ||
await FileManager_1.FileManager.writeFile(plistFilePath, plistFile); | ||
} | ||
static async updateNSEBundleShortVersion(version) { | ||
let plistFile = await ReaderManager_1.ReaderManager.readFile(plistFilePath); | ||
async updateNSEBundleShortVersion(version) { | ||
const plistFilePath = `${this.nsePath}/${plistFileName}`; | ||
let plistFile = await FileManager_1.FileManager.readFile(plistFilePath); | ||
plistFile = plistFile.replace(iosConstants_1.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX, version); | ||
fs.writeFile(plistFilePath, plistFile, 'utf-8', err => { | ||
logIfError(err); | ||
}); | ||
await FileManager_1.FileManager.writeFile(plistFilePath, plistFile); | ||
} | ||
} | ||
exports.default = NseUpdaterManager; |
@@ -10,5 +10,5 @@ "use strict"; | ||
const OneSignalLog_1 = require("./OneSignalLog"); | ||
const ReaderManager_1 = require("./ReaderManager"); | ||
const FileManager_1 = require("./FileManager"); | ||
async function updatePodfile(iosPath) { | ||
const podfile = await ReaderManager_1.ReaderManager.readFile(`${iosPath}/Podfile`); | ||
const podfile = await FileManager_1.FileManager.readFile(`${iosPath}/Podfile`); | ||
const matches = podfile.match(iosConstants_1.NSE_PODFILE_REGEX); | ||
@@ -15,0 +15,0 @@ if (matches) { |
@@ -19,2 +19,3 @@ /** | ||
IPHONEOS_DEPLOYMENT_TARGET, | ||
NSE_TARGET_NAME, | ||
TARGETED_DEVICE_FAMILY | ||
@@ -25,2 +26,3 @@ } from "../support/iosConstants"; | ||
import { OneSignalLog } from "../support/OneSignalLog"; | ||
import { FileManager } from "../support/FileManager"; | ||
@@ -92,4 +94,4 @@ /* I N T E R F A C E S */ | ||
} | ||
let modResultsArray = (newConfig.modResults[APP_GROUP_KEY] as Array<any>); | ||
let entitlement = `group.${newConfig?.ios?.bundleIdentifier || ""}.onesignal`; | ||
const modResultsArray = (newConfig.modResults[APP_GROUP_KEY] as Array<any>); | ||
const entitlement = `group.${newConfig?.ios?.bundleIdentifier || ""}.onesignal`; | ||
if (modResultsArray.indexOf(entitlement) !== -1) { | ||
@@ -136,3 +138,2 @@ return newConfig; | ||
export function xcodeProjectAddNse( | ||
@@ -145,9 +146,6 @@ appName: string, | ||
updatePodfile(iosPath); | ||
NseUpdaterManager.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`) | ||
NseUpdaterManager.updateNSEBundleVersion(bundleVersion ?? DEFAULT_BUNDLE_VERSION); | ||
NseUpdaterManager.updateNSEBundleShortVersion(bundleShortVersion ?? DEFAULT_BUNDLE_SHORT_VERSION); | ||
// not awaiting in order to not block main thread | ||
updatePodfile(iosPath).catch(err => { OneSignalLog.error(err) }); | ||
const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`; | ||
const targetName = "OneSignalNotificationServiceExtension"; | ||
@@ -157,4 +155,4 @@ const extFiles = [ | ||
"NotificationService.m", | ||
`${targetName}.entitlements`, | ||
`${targetName}-Info.plist` | ||
`${NSE_TARGET_NAME}.entitlements`, | ||
`${NSE_TARGET_NAME}-Info.plist` | ||
]; | ||
@@ -164,3 +162,3 @@ | ||
xcodeProject.parse(function(err: Error) { | ||
xcodeProject.parse(async function(err: Error) { | ||
if (err) { | ||
@@ -171,24 +169,23 @@ OneSignalLog.log(`Error parsing iOS project: ${JSON.stringify(err)}`); | ||
// Copy in the extension files | ||
fs.mkdirSync(`${iosPath}/${targetName}`, { recursive: true }); | ||
extFiles.forEach(function (extFile) { | ||
let targetFile = `${iosPath}/${targetName}/${extFile}`; | ||
/* COPY OVER EXTENSION FILES */ | ||
fs.mkdirSync(`${iosPath}/${NSE_TARGET_NAME}`, { recursive: true }); | ||
try { | ||
fs.createReadStream(`${sourceDir}${extFile}`).pipe( | ||
fs.createWriteStream(targetFile) | ||
); | ||
} catch (err) { | ||
OneSignalLog.log(err as string); | ||
} | ||
}); | ||
for(let i = 0; i < extFiles.length; i++) { | ||
const extFile = extFiles[i]; | ||
const targetFile = `${iosPath}/${NSE_TARGET_NAME}/${extFile}`; | ||
await FileManager.copyFile(`${sourceDir}${extFile}`, targetFile); | ||
} | ||
const projObjects = xcodeProject.hash.project.objects; | ||
/* MODIFY COPIED EXTENSION FILES */ | ||
const nseUpdater = new NseUpdaterManager(iosPath); | ||
await nseUpdater.updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`) | ||
await nseUpdater.updateNSEBundleVersion(bundleVersion ?? DEFAULT_BUNDLE_VERSION); | ||
await nseUpdater.updateNSEBundleShortVersion(bundleShortVersion ?? DEFAULT_BUNDLE_SHORT_VERSION); | ||
// Create new PBXGroup for the extension | ||
let extGroup = xcodeProject.addPbxGroup(extFiles, targetName, targetName); | ||
const extGroup = xcodeProject.addPbxGroup(extFiles, NSE_TARGET_NAME, NSE_TARGET_NAME); | ||
// Add the new PBXGroup to the top level group. This makes the | ||
// files / folder appear in the file explorer in Xcode. | ||
let groups = xcodeProject.hash.project.objects["PBXGroup"]; | ||
const groups = xcodeProject.hash.project.objects["PBXGroup"]; | ||
Object.keys(groups).forEach(function (key) { | ||
@@ -204,7 +201,8 @@ if (groups[key].name === undefined) { | ||
// - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860 | ||
const projObjects = xcodeProject.hash.project.objects; | ||
projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {}; | ||
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {}; | ||
if (!!xcodeProject.pbxTargetByName(targetName)) { | ||
OneSignalLog.log(`${targetName} already exists in project. Skipping...`); | ||
if (!!xcodeProject.pbxTargetByName(NSE_TARGET_NAME)) { | ||
OneSignalLog.log(`${NSE_TARGET_NAME} already exists in project. Skipping...`); | ||
return; | ||
@@ -215,3 +213,3 @@ } | ||
// This adds PBXTargetDependency and PBXContainerItemProxy for you | ||
const nseTarget = xcodeProject.addTarget(targetName, "app_extension", targetName, `${bundleIdentifier}.${targetName}`); | ||
const nseTarget = xcodeProject.addTarget(NSE_TARGET_NAME, "app_extension", NSE_TARGET_NAME, `${bundleIdentifier}.${NSE_TARGET_NAME}`); | ||
@@ -236,13 +234,13 @@ // Add build phases to the new target | ||
// However, can be more | ||
let configurations = xcodeProject.pbxXCBuildConfigurationSection(); | ||
for (let key in configurations) { | ||
const configurations = xcodeProject.pbxXCBuildConfigurationSection(); | ||
for (const key in configurations) { | ||
if ( | ||
typeof configurations[key].buildSettings !== "undefined" && | ||
configurations[key].buildSettings.PRODUCT_NAME == `"${targetName}"` | ||
configurations[key].buildSettings.PRODUCT_NAME == `"${NSE_TARGET_NAME}"` | ||
) { | ||
let buildSettingsObj = configurations[key].buildSettings; | ||
const buildSettingsObj = configurations[key].buildSettings; | ||
buildSettingsObj.DEVELOPMENT_TEAM = devTeam; | ||
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iPhoneDeploymentTarget ?? IPHONEOS_DEPLOYMENT_TARGET; | ||
buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY; | ||
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${targetName}/${targetName}.entitlements`; | ||
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${NSE_TARGET_NAME}/${NSE_TARGET_NAME}.entitlements`; | ||
buildSettingsObj.CODE_SIGN_STYLE = "Automatic"; | ||
@@ -249,0 +247,0 @@ } |
{ | ||
"name": "onesignal-expo-plugin", | ||
"version": "1.0.0-beta10", | ||
"version": "1.0.0-beta11", | ||
"description": "The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.", | ||
@@ -8,3 +8,4 @@ "main": "./app.plugin.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "rm -rf build && tsc && cp -a support/serviceExtensionFiles build/support/", | ||
"build": "yarn run lint && rm -rf build && tsc && cp -a support/serviceExtensionFiles build/support/", | ||
"lint": "eslint . --ext .ts", | ||
"prepare": "yarn run build" | ||
@@ -35,9 +36,12 @@ }, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.10.1", | ||
"@typescript-eslint/parser": "^5.10.1", | ||
"eslint": "^8.8.0", | ||
"expo-module-scripts": "^2.0.0", | ||
"readme-md-generator": "^1.0.0" | ||
"readme-md-generator": "^1.0.0", | ||
"typescript": "^4.5.5" | ||
}, | ||
"dependencies": { | ||
"react-native-onesignal": "^4.3.1", | ||
"xcode": "^3.0.1" | ||
} | ||
} |
<h1 align="center">Welcome to onesignal-expo-plugin 👋</h1> | ||
<p> | ||
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0--beta10-blue.svg?cacheSeconds=2592000" /> | ||
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0--beta11-blue.svg?cacheSeconds=2592000" /> | ||
<a href="https://github.com/OneSignal/onesignal-expo-plugin#readme" target="_blank"> | ||
@@ -5,0 +5,0 @@ <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" /> |
export const IPHONEOS_DEPLOYMENT_TARGET = "11.0"; | ||
export const TARGETED_DEVICE_FAMILY = `\"1,2\"`; | ||
export const TARGETED_DEVICE_FAMILY = `"1,2"`; | ||
@@ -17,1 +17,3 @@ export const NSE_PODFILE_SNIPPET = ` | ||
export const DEFAULT_BUNDLE_SHORT_VERSION = '1.0'; | ||
export const NSE_TARGET_NAME = "OneSignalNotificationServiceExtension"; |
@@ -1,42 +0,39 @@ | ||
import * as fs from 'fs'; | ||
import { BUNDLE_SHORT_VERSION_TEMPLATE_REGEX, BUNDLE_VERSION_TEMPLATE_REGEX, GROUP_IDENTIFIER_TEMPLATE_REGEX } from './iosConstants'; | ||
import { OneSignalLog } from './OneSignalLog'; | ||
import { ReaderManager } from './ReaderManager'; | ||
import { FileManager } from './FileManager'; | ||
import { | ||
BUNDLE_SHORT_VERSION_TEMPLATE_REGEX, | ||
BUNDLE_VERSION_TEMPLATE_REGEX, | ||
GROUP_IDENTIFIER_TEMPLATE_REGEX, | ||
NSE_TARGET_NAME | ||
} from './iosConstants'; | ||
const entitlementsFilePath =`${__dirname}/serviceExtensionFiles/OneSignalNotificationServiceExtension.entitlements`; | ||
const plistFilePath = `${__dirname}/serviceExtensionFiles/OneSignalNotificationServiceExtension-Info.plist`; | ||
// project `ios/OneSignalNotificationServiceExtension` directory | ||
const entitlementsFileName =`OneSignalNotificationServiceExtension.entitlements`; | ||
const plistFileName = `OneSignalNotificationServiceExtension-Info.plist`; | ||
const logIfError = (err: NodeJS.ErrnoException | null) => { | ||
if (err) { | ||
OneSignalLog.error("Error updating OneSignal NSE Entitlement File."); | ||
export default class NseUpdaterManager { | ||
private nsePath = ''; | ||
constructor(iosPath: string) { | ||
this.nsePath = `${iosPath}/${NSE_TARGET_NAME}`; | ||
} | ||
} | ||
export default class NseUpdaterManager { | ||
static async updateNSEEntitlements(groupIdentifier: string) { | ||
let entitlementsFile = await ReaderManager.readFile(entitlementsFilePath); | ||
async updateNSEEntitlements(groupIdentifier: string): Promise<void> { | ||
const entitlementsFilePath = `${this.nsePath}/${entitlementsFileName}`; | ||
let entitlementsFile = await FileManager.readFile(entitlementsFilePath); | ||
entitlementsFile = entitlementsFile.replace(GROUP_IDENTIFIER_TEMPLATE_REGEX, groupIdentifier); | ||
fs.writeFile(entitlementsFilePath, entitlementsFile, 'utf-8', (err) => { | ||
logIfError(err); | ||
}) | ||
await FileManager.writeFile(entitlementsFilePath, entitlementsFile); | ||
} | ||
static async updateNSEBundleVersion(version: string) { | ||
let plistFile = await ReaderManager.readFile(plistFilePath); | ||
async updateNSEBundleVersion(version: string): Promise<void> { | ||
const plistFilePath = `${this.nsePath}/${plistFileName}`; | ||
let plistFile = await FileManager.readFile(plistFilePath); | ||
plistFile = plistFile.replace(BUNDLE_VERSION_TEMPLATE_REGEX, version); | ||
fs.writeFile(plistFilePath, plistFile, 'utf-8', err => { | ||
logIfError(err); | ||
}); | ||
await FileManager.writeFile(plistFilePath, plistFile); | ||
} | ||
static async updateNSEBundleShortVersion(version: string) { | ||
let plistFile = await ReaderManager.readFile(plistFilePath); | ||
async updateNSEBundleShortVersion(version: string): Promise<void> { | ||
const plistFilePath = `${this.nsePath}/${plistFileName}`; | ||
let plistFile = await FileManager.readFile(plistFilePath); | ||
plistFile = plistFile.replace(BUNDLE_SHORT_VERSION_TEMPLATE_REGEX, version); | ||
fs.writeFile(plistFilePath, plistFile, 'utf-8', err => { | ||
logIfError(err); | ||
}); | ||
await FileManager.writeFile(plistFilePath, plistFile); | ||
} | ||
} |
import fs from 'fs'; | ||
import { NSE_PODFILE_REGEX, NSE_PODFILE_SNIPPET } from './iosConstants'; | ||
import { OneSignalLog } from './OneSignalLog'; | ||
import { ReaderManager } from './ReaderManager'; | ||
import { FileManager } from './FileManager'; | ||
export async function updatePodfile(iosPath: string) { | ||
const podfile = await ReaderManager.readFile(`${iosPath}/Podfile`); | ||
const podfile = await FileManager.readFile(`${iosPath}/Podfile`); | ||
const matches = podfile.match(NSE_PODFILE_REGEX); | ||
@@ -9,0 +9,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
53018
1
37
856
3
0
6
- Removedreact-native-onesignal@^4.3.1
- Removedinvariant@2.2.4(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedreact-native-onesignal@4.5.4(transitive)