react-native-notificare-push
Version:
Notificare Push React Native module.
38 lines (37 loc) • 1.8 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateNotificationServicePlist = updateNotificationServicePlist;
const plist_1 = __importDefault(require("@expo/plist"));
const fs_1 = __importDefault(require("fs"));
const constantsIOS_1 = require("../../constants/constantsIOS");
function updateNotificationServicePlist(projRoot, bundleVersion, bundleShortVersion) {
let extInfoPlist;
const extPlistPath = `${projRoot}/ios/${constantsIOS_1.NOTIFICARE_NOTIFICATION_SERVICE_EXTENSION}/${constantsIOS_1.NOTIFICARE_NOTIFICATION_SERVICE_EXTENSION}-Info.plist`;
try {
extInfoPlist = plist_1.default.parse(fs_1.default.readFileSync(extPlistPath, 'utf8'));
}
catch (e) {
console.log(`Failed to parse ${constantsIOS_1.NOTIFICARE_NOTIFICATION_SERVICE_EXTENSION}-Info.plist: ${e}`);
}
if (!extInfoPlist) {
return;
}
try {
if (bundleVersion) {
extInfoPlist.CFBundleVersion = bundleVersion;
}
if (bundleShortVersion) {
extInfoPlist.CFBundleShortVersionString = bundleShortVersion;
}
let info_contents = plist_1.default.build(extInfoPlist, { indent: '\t', offset: -1 });
info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g, '<string></string>');
fs_1.default.writeFileSync(extPlistPath, info_contents, 'utf-8');
console.log(`Successfully updated ${constantsIOS_1.NOTIFICARE_NOTIFICATION_SERVICE_EXTENSION}-Info.plist.`);
}
catch (e) {
console.error(`Failed to update ${constantsIOS_1.NOTIFICARE_NOTIFICATION_SERVICE_EXTENSION}-Info.plist: ${e}`);
}
}
;