Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

onesignal-expo-plugin

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onesignal-expo-plugin - npm Package Compare versions

Comparing version 1.0.0-beta9 to 1.0.0

.eslintignore

26

build/onesignal/withOneSignalAndroid.js

@@ -9,22 +9,18 @@ "use strict";

const config_plugins_1 = require("@expo/config-plugins");
// ---------- ---------- ---------- ----------
const oneSignalGradle = `
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'`;
// ---------- ---------- ---------- ----------
const androidConstants_1 = require("../support/androidConstants");
const OneSignalLog_1 = require("../support/OneSignalLog");
const withGradleBuildConfig = (config) => {
return (0, config_plugins_1.withAppBuildGradle)(config, (newConfig) => {
newConfig.modResults.contents = `${oneSignalGradle.trimStart()}\n\n${newConfig.modResults.contents}`;
let { contents } = newConfig.modResults;
// make sure we haven't previously added dependencies
if (!contents.includes(androidConstants_1.ONESIGNAL_GRADLE)) {
contents = `${androidConstants_1.ONESIGNAL_GRADLE}\n${contents}`;
}
else {
OneSignalLog_1.OneSignalLog.log("OneSignal dependencies already added to build.gradle. Skipping...");
}
newConfig.modResults.contents = contents;
return newConfig;
});
};
// ---------- ---------- ---------- ----------
const withOneSignalAndroid = (config, props) => {

@@ -31,0 +27,0 @@ withGradleBuildConfig(config, props);

@@ -6,2 +6,21 @@ "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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -13,8 +32,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const config_plugins_1 = require("@expo/config-plugins");
const fs_1 = __importDefault(require("fs"));
const fs = __importStar(require("fs"));
const xcode_1 = __importDefault(require("xcode"));
const iosConstants_1 = require("../support/iosConstants");
const updatePodfile_1 = require("../support/updatePodfile");
const updateNSEEntitlements_1 = require("../support/updateNSEEntitlements");
// ---------- ---------- ---------- ----------
const NseUpdaterManager_1 = __importDefault(require("../support/NseUpdaterManager"));
const OneSignalLog_1 = require("../support/OneSignalLog");
const FileManager_1 = require("../support/FileManager");
/**

@@ -60,3 +80,3 @@ * Add 'app-environment' record with current environment to '<project-name>.entitlements' file

const APP_GROUP_KEY = "com.apple.security.application-groups";
return (0, config_plugins_1.withEntitlementsPlist)(config, (newConfig) => {
return (0, config_plugins_1.withEntitlementsPlist)(config, newConfig => {
var _a;

@@ -66,3 +86,8 @@ if (!Array.isArray(newConfig.modResults[APP_GROUP_KEY])) {

}
newConfig.modResults[APP_GROUP_KEY].push(`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) {
return newConfig;
}
modResultsArray.push(entitlement);
return newConfig;

@@ -73,3 +98,3 @@ });

return (0, config_plugins_1.withXcodeProject)(config, async (props) => {
var _a;
var _a, _b;
const options = {

@@ -79,2 +104,4 @@ iosPath: props.modRequest.platformProjectRoot,

devTeam: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.devTeam,
bundleVersion: (_b = props.ios) === null || _b === void 0 ? void 0 : _b.buildNumber,
bundleShortVersion: props === null || props === void 0 ? void 0 : props.version,
iPhoneDeploymentTarget: onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.iPhoneDeploymentTarget

@@ -86,3 +113,2 @@ };

};
// ---------- ---------- ---------- ----------
const withOneSignalIos = (config, props) => {

@@ -97,36 +123,35 @@ withAppEnvironment(config, props);

function xcodeProjectAddNse(appName, options, sourceDir) {
const { iosPath, devTeam, bundleIdentifier, iPhoneDeploymentTarget } = options;
(0, updatePodfile_1.updatePodfile)(iosPath);
(0, updateNSEEntitlements_1.updateNSEEntitlements)(`group.${bundleIdentifier}.onesignal`);
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget } = options;
// 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) {
console.log(`Error parsing iOS project: ${JSON.stringify(err)}`);
OneSignalLog_1.OneSignalLog.log(`Error parsing iOS project: ${JSON.stringify(err)}`);
return;
}
// Copy in the extension files
fs_1.default.mkdirSync(`${iosPath}/${targetName}`, { recursive: true });
extFiles.forEach(function (extFile) {
let targetFile = `${iosPath}/${targetName}/${extFile}`;
try {
fs_1.default.createReadStream(`${sourceDir}${extFile}`).pipe(fs_1.default.createWriteStream(targetFile));
}
catch (err) {
console.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) {

@@ -141,6 +166,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)) {
console.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;

@@ -150,3 +176,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

@@ -158,11 +184,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";

@@ -174,5 +200,5 @@ }

xcodeProject.addTargetAttribute("DevelopmentTeam", devTeam);
fs_1.default.writeFileSync(projPath, xcodeProject.writeSync());
fs.writeFileSync(projPath, xcodeProject.writeSync());
});
}
exports.xcodeProjectAddNse = xcodeProjectAddNse;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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 = `

@@ -12,1 +12,6 @@ target 'OneSignalNotificationServiceExtension' do

exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
exports.BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
exports.DEFAULT_BUNDLE_VERSION = '1';
exports.DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
exports.NSE_TARGET_NAME = "OneSignalNotificationServiceExtension";

@@ -9,8 +9,9 @@ "use strict";

const iosConstants_1 = require("./iosConstants");
const ReaderManager_1 = require("./ReaderManager");
const OneSignalLog_1 = require("./OneSignalLog");
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);
if (matches) {
console.info("OneSignalNotificationServiceExtension target already added to Podfile. Skipping...");
OneSignalLog_1.OneSignalLog.log("OneSignalNotificationServiceExtension target already added to Podfile. Skipping...");
}

@@ -20,3 +21,3 @@ else {

if (err) {
console.error("Error writing to Podfile");
OneSignalLog_1.OneSignalLog.error("Error writing to Podfile");
}

@@ -23,0 +24,0 @@ });

@@ -7,23 +7,18 @@ /**

import { ConfigPlugin, withAppBuildGradle } from '@expo/config-plugins';
import { ONESIGNAL_GRADLE } from '../support/androidConstants';
import { OneSignalLog } from '../support/OneSignalLog';
import { OneSignalPluginProps } from './withOneSignal';
// ---------- ---------- ---------- ----------
const oneSignalGradle = `
buildscript {
repositories {
gradlePluginPortal()
const withGradleBuildConfig: ConfigPlugin<OneSignalPluginProps> = (config) => {
return withAppBuildGradle(config, (newConfig) => {
let { contents } = newConfig.modResults;
// make sure we haven't previously added dependencies
if (!contents.includes(ONESIGNAL_GRADLE)) {
contents = `${ONESIGNAL_GRADLE}\n${contents}`;
} else {
OneSignalLog.log("OneSignal dependencies already added to build.gradle. Skipping...");
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'`;
// ---------- ---------- ---------- ----------
const withGradleBuildConfig: ConfigPlugin<OneSignalPluginProps> = (config) => {
return withAppBuildGradle(config, (newConfig) => {
newConfig.modResults.contents = `${oneSignalGradle.trimStart()}\n\n${
newConfig.modResults.contents
}`;
newConfig.modResults.contents = contents;
return newConfig;

@@ -33,3 +28,2 @@ });

// ---------- ---------- ---------- ----------
export const withOneSignalAndroid: ConfigPlugin<OneSignalPluginProps> = (

@@ -36,0 +30,0 @@ config,

@@ -13,18 +13,26 @@ /**

import { OneSignalPluginProps } from "./withOneSignal";
import fs from 'fs';
import * as fs from 'fs';
import xcode from 'xcode';
import { IPHONEOS_DEPLOYMENT_TARGET, TARGETED_DEVICE_FAMILY } from "../support/iosConstants";
import {
DEFAULT_BUNDLE_SHORT_VERSION,
DEFAULT_BUNDLE_VERSION,
IPHONEOS_DEPLOYMENT_TARGET,
NSE_TARGET_NAME,
TARGETED_DEVICE_FAMILY
} from "../support/iosConstants";
import { updatePodfile } from "../support/updatePodfile";
import { updateNSEEntitlements } from "../support/updateNSEEntitlements";
import NseUpdaterManager from "../support/NseUpdaterManager";
import { OneSignalLog } from "../support/OneSignalLog";
import { FileManager } from "../support/FileManager";
/* I N T E R F A C E S */
interface PluginOptions {
iosPath: string,
devTeam?: string,
bundleIdentifier?: string,
iPhoneDeploymentTarget?: string
iosPath: string,
devTeam?: string,
bundleVersion?: string,
bundleShortVersion?: string,
bundleIdentifier?: string,
iPhoneDeploymentTarget?: string
}
// ---------- ---------- ---------- ----------
/**

@@ -81,9 +89,12 @@ * Add 'app-environment' record with current environment to '<project-name>.entitlements' file

const APP_GROUP_KEY = "com.apple.security.application-groups";
return withEntitlementsPlist(config, (newConfig) => {
return withEntitlementsPlist(config, newConfig => {
if (!Array.isArray(newConfig.modResults[APP_GROUP_KEY])) {
newConfig.modResults[APP_GROUP_KEY] = [];
}
(newConfig.modResults[APP_GROUP_KEY] as Array<any>).push(
`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) {
return newConfig;
}
modResultsArray.push(entitlement);

@@ -100,2 +111,4 @@ return newConfig;

devTeam: onesignalProps?.devTeam,
bundleVersion: props.ios?.buildNumber,
bundleShortVersion: props?.version,
iPhoneDeploymentTarget: onesignalProps?.iPhoneDeploymentTarget

@@ -114,3 +127,2 @@ };

// ---------- ---------- ---------- ----------
export const withOneSignalIos: ConfigPlugin<OneSignalPluginProps> = (

@@ -127,3 +139,2 @@ config,

export function xcodeProjectAddNse(

@@ -134,9 +145,8 @@ appName: string,

): void {
const { iosPath, devTeam, bundleIdentifier, iPhoneDeploymentTarget } = options;
const { iosPath, devTeam, bundleIdentifier, bundleVersion, bundleShortVersion, iPhoneDeploymentTarget } = options;
updatePodfile(iosPath);
updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`)
// 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";

@@ -146,4 +156,4 @@ const extFiles = [

"NotificationService.m",
`${targetName}.entitlements`,
`${targetName}-Info.plist`
`${NSE_TARGET_NAME}.entitlements`,
`${NSE_TARGET_NAME}-Info.plist`
];

@@ -153,30 +163,29 @@

xcodeProject.parse(function(err: Error) {
xcodeProject.parse(async function(err: Error) {
if (err) {
console.log(`Error parsing iOS project: ${JSON.stringify(err)}`);
OneSignalLog.log(`Error parsing iOS project: ${JSON.stringify(err)}`);
return;
}
// 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) {
console.log(err);
}
});
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) {

@@ -192,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)) {
console.log(targetName, "already exists in project. Skipping...");
if (!!xcodeProject.pbxTargetByName(NSE_TARGET_NAME)) {
OneSignalLog.log(`${NSE_TARGET_NAME} already exists in project. Skipping...`);
return;

@@ -203,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}`);

@@ -224,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";

@@ -237,0 +247,0 @@ }

{
"name": "onesignal-expo-plugin",
"version": "1.0.0-beta9",
"version": "1.0.0",
"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--beta9-blue.svg?cacheSeconds=2592000" />
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
<a href="https://github.com/OneSignal/onesignal-expo-plugin#readme" target="_blank">

@@ -20,3 +20,2 @@ <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />

## 🚧 In Beta 🚧
## Overview

@@ -36,2 +35,7 @@ This plugin is an [Expo Config Plugin](https://docs.expo.dev/guides/config-plugins/). It extends the Expo config to allow customizing the prebuild phase of managed workflow builds (no need to eject to a bare workflow). For the purposes of OneSignal integration, the plugin facilitates automatically generating/configuring the necessary native code files needed to get the [OneSignal React-Native SDK](https://github.com/OneSignal/react-native-onesignal) to work. You can think of adding a plugin as adding custom native code.

expo install onesignal-expo-plugin
# npm
npm install react-native-onesignal
# yarn
yarn add react-native-onesignal

@@ -110,11 +114,40 @@ ```

### Versioning
In your configuration file, make sure you set:
| Property | Details |
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `version` | Your app version. Corresponds to `CFBundleShortVersionString` on iOS. This value will be used in your NSE* target's plist file. |
| `ios.buildNumber` | Build number for your iOS standalone app. Corresponds to `CFBundleVersion` and must match Apple's specified format. This value will be used in your NSE* target's plist file. |
\* NSE = Notification Service Extension. Learn more about the NSE [here](https://documentation.onesignal.com/docs/service-extensions).
## EAS (Expo Application Services)
See our [EAS documentation](EAS.md) for help with EAS.
### iOS Credentials: OneSignal + EAS
To distribute your iOS application via EAS, you will need to ensure your credentials are set up correctly. See our [credentials setup guide for instructions](IOS_CREDENTIALS_EAS.md).
## Prebuild
Since we are using custom native code (via the OneSignal plugin), we need to generate the native runtime code for the project. By prebuilding, we automatically link and configure the native modules that have implemented CocoaPods, autolinking, and other config plugins. You can think of prebuild like a native code bundler.
When you run `expo prebuild` we enter into a custom managed workflow which provides most of the benefits of bare workflows and managed workflows at the same time.
```sh
expo prebuild
```
```sh
# nukes changes and rebuilds
expo prebuild --clean
```
## Run
The following commands will prebuild *and* run your application. Note that for iOS, push notifications will **not** work in the Simulator.
```sh
$ expo prebuild --clean
# Build and run your native iOS project
expo run:ios
# Build your native iOS project
$ expo run:ios
# Build your native Android project
$ expo run:android
# Build and run your native Android project
expo run:android
```

@@ -121,0 +154,0 @@

export const IPHONEOS_DEPLOYMENT_TARGET = "11.0";
export const TARGETED_DEVICE_FAMILY = `\"1,2\"`;
export const TARGETED_DEVICE_FAMILY = `"1,2"`;

@@ -12,1 +12,8 @@ export const NSE_PODFILE_SNIPPET = `

export const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
export const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
export const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
export const DEFAULT_BUNDLE_VERSION = '1';
export const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
export const NSE_TARGET_NAME = "OneSignalNotificationServiceExtension";
import fs from 'fs';
import { NSE_PODFILE_REGEX, NSE_PODFILE_SNIPPET } from './iosConstants';
import { ReaderManager } from './ReaderManager';
import { OneSignalLog } from './OneSignalLog';
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);
if (matches) {
console.info("OneSignalNotificationServiceExtension target already added to Podfile. Skipping...");
OneSignalLog.log("OneSignalNotificationServiceExtension target already added to Podfile. Skipping...");
} else {
fs.appendFile(`${iosPath}/Podfile`, NSE_PODFILE_SNIPPET, (err) => {
if (err) {
console.error("Error writing to Podfile");
OneSignalLog.error("Error writing to Podfile");
}

@@ -16,0 +17,0 @@ })

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc