mx-jpush-expo
Version:
Expo 集成极光推送(JPush)一体化解决方案,支持 iOS/Android 厂商通道
44 lines • 1.52 kB
JavaScript
;
/**
* iOS Info.plist 配置
* 参考: https://juejin.cn/post/7554288083597885467
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeBackgroundModes = mergeBackgroundModes;
exports.applyIosInfoPlist = applyIosInfoPlist;
exports.withIosInfoPlist = withIosInfoPlist;
const config_plugins_1 = require("expo/config-plugins");
const REQUIRED_BACKGROUND_MODES = ['fetch', 'remote-notification'];
function mergeBackgroundModes(existingModes) {
const mergedModes = new Set(Array.isArray(existingModes)
? existingModes
: typeof existingModes === 'string'
? [existingModes]
: []);
for (const mode of REQUIRED_BACKGROUND_MODES) {
mergedModes.add(mode);
}
return Array.from(mergedModes);
}
/**
* 配置 iOS Info.plist
* 添加推送通知所需的后台模式
*/
/**
* 配置 iOS Info.plist
* 添加推送通知所需的后台模式
*/
function applyIosInfoPlist(infoPlist, props) {
infoPlist.UIBackgroundModes = mergeBackgroundModes(infoPlist.UIBackgroundModes);
infoPlist.JPUSH_APPKEY = props.appKey;
infoPlist.JPUSH_CHANNEL = props.channel;
infoPlist.JPUSH_APS_FOR_PRODUCTION = props.apsForProduction;
return infoPlist;
}
function withIosInfoPlist(config, props) {
return (0, config_plugins_1.withInfoPlist)(config, (nextConfig) => {
nextConfig.modResults = applyIosInfoPlist(nextConfig.modResults, props);
return nextConfig;
});
}
//# sourceMappingURL=infoPlist.js.map