Skip to content

integrateUniPushIOS ​

集成 DCloud UniPush(iOS 离线打包):同步 PandoraApi.bundle/feature.plist 的 Push 节点、链接依赖,并写入后台推送所需的 Info.plist / entitlements。

文档:https://nativesupport.dcloud.net.cn/AppDocs/usemodule/iOSModuleConfig/push

函数签名 ​

typescript
function integrateUniPushIOS(
  projectPath: string,
  projectName: string,
  bundleId: string,
  config: UniPushIOSConfig,
  deps: IntegrateIOSThirdPartyModuleDeps,
): Promise<{ success: boolean; message?: string; error?: string; logs: string[] }>

Push 节点 ​

SDK 自带的 Push 节点只有 baseclass=PGPush、server.class=PGPushServer,不会启用 UniPush。集成时会改成文档要求的结构:class=PGPushActualize,server.class=PGPushServerAct。

feature.plist 不在 {projectPath}/{projectName}/PandoraApi.bundle。官方路径是 {sdkRoot}/SDK/Bundles/PandoraApi.bundle。

查找顺序:

  1. pandoraApiBundlePath(传入后只认这一处,找不到即失败)
  2. {projectPath}/{projectName}/PandoraApi.bundle
  3. {sdkPath}/SDK/Bundles/PandoraApi.bundle(以及 {sdkPath}/Bundles/PandoraApi.bundle)
  4. {projectPath}/../SDK/Bundles/PandoraApi.bundle
  5. {projectPath}/SDK/Bundles/PandoraApi.bundle

都找不到时返回 success: false,不会再继续拷贝静态库。syncFeaturePlistPush: false 可跳过这一步,此时 UniPush 不会生效。

还会写入 ​

项默认说明
Info.plist getui有字段才写appid / appkey / appsecret
UIBackgroundModes = remote-notification开启enableRemoteNotificationBackgroundMode: false 可跳过
entitlements aps-environmentdevelopmentproduction 用于发布描述文件;false 跳过。buildIOSApp 在未传时按 Debug / Release 选择
Xcode Push Notifications尽量写入project.pbxproj 的 com.apple.Push 与 CODE_SIGN_ENTITLEMENTS。写不进去时日志会要求在 Signing & Capabilities 里手动添加

APNs 证书和带 Push 的 Provisioning Profile 仍需在 Apple 后台配置,且 aps-environment 要和描述文件一致。