feat(notification): improve JPush integration and message sync reliability - Update iOS bundle identifier to `cn.qczlit.weiyou` - Add `withSigning` Expo plugin - Enhance `withJPush` plugin with improved Swift AppDelegate injection logic - Update JPush default channel to `developer-default` - Optimize `MessageSyncService` to prevent race conditions in unread count updates - Implement promise deduplication for `fetchUnreadCount` to prevent redundant network requests - Add `setConversationsWithUnread` to `useMessageStore` for atomic state updates of conversations and unread counts
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
const { withDangerousMod } = require('@expo/config-plugins');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const withSigning = (config, options = {}) => {
|
|
const { teamId = 'X3964MGXHG' } = options;
|
|
|
|
config = withDangerousMod(config, [
|
|
'ios',
|
|
async (config) => {
|
|
const platformRoot = config.modRequest.platformProjectRoot;
|
|
|
|
// 1. Inject CODE_SIGN_STYLE and DEVELOPMENT_TEAM into pbxproj
|
|
const pbxprojPath = path.join(platformRoot, 'app.xcodeproj', 'project.pbxproj');
|
|
if (fs.existsSync(pbxprojPath)) {
|
|
let contents = fs.readFileSync(pbxprojPath, 'utf-8');
|
|
const entitlementsLine = 'CODE_SIGN_ENTITLEMENTS = app/app.entitlements;';
|
|
const signingBlock = `${entitlementsLine}\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = ${teamId};`;
|
|
contents = contents.replaceAll(entitlementsLine, signingBlock);
|
|
fs.writeFileSync(pbxprojPath, contents);
|
|
}
|
|
|
|
// 2. Set aps-environment to production in entitlements
|
|
const entitlementsPath = path.join(platformRoot, 'app', 'app.entitlements');
|
|
if (fs.existsSync(entitlementsPath)) {
|
|
let entitlements = fs.readFileSync(entitlementsPath, 'utf-8');
|
|
entitlements = entitlements.replace(
|
|
/<key>aps-environment<\/key>\s*<string>development<\/string>/,
|
|
'<key>aps-environment</key>\n\t<string>production</string>'
|
|
);
|
|
fs.writeFileSync(entitlementsPath, entitlements);
|
|
}
|
|
|
|
return config;
|
|
},
|
|
]);
|
|
|
|
return config;
|
|
};
|
|
|
|
module.exports = withSigning; |